LinuxCommandLibrary

aws-s3-sync

Synchronize directories and S3 prefixes

TLDR

Sync a local directory to an S3 bucket

$ aws s3 sync [./local-dir] s3://[bucket-name]/
copy
Download S3 bucket to local directory
$ aws s3 sync s3://[bucket-name]/ [./local-dir]
copy
Sync between two S3 buckets
$ aws s3 sync s3://[source-bucket] s3://[dest-bucket]
copy
Sync and delete files not in source
$ aws s3 sync [./local-dir] s3://[bucket-name]/ --delete
copy
Sync excluding certain file types
$ aws s3 sync [./local-dir] s3://[bucket-name]/ --exclude "*.log"
copy
Preview sync operation without executing
$ aws s3 sync [./local-dir] s3://[bucket-name]/ --dryrun
copy
Sync only new files without overwriting
$ aws s3 sync [./local-dir] s3://[bucket-name]/ --no-overwrite
copy

SYNOPSIS

aws s3 sync source destination [options]

DESCRIPTION

aws s3 sync synchronizes directories and S3 prefixes by recursively copying new and updated files from the source to the destination. It only transfers files that are new or have changed, making it efficient for incremental backups and deployments.
By default, sync compares file size and last modified time to determine which files need updating. It creates folders in the destination only if they contain files.

PARAMETERS

--delete

Delete destination files that don't exist in the source
--dryrun
Display operations that would be performed without executing them
--quiet
Suppress all output except errors
--no-overwrite
Only transfer files not present at the destination
--size-only
Use file size alone to determine if sync is needed (ignore timestamps)
--exact-timestamps
Match timestamps exactly when syncing from S3 to local
--include pattern
Include files matching the pattern
--exclude pattern
Exclude files matching the pattern from the sync
--acl value
Set access control list: private, public-read, etc.
--storage-class value
Specify storage class: STANDARD, STANDARD_IA, GLACIER, etc.
--source-region value
Source bucket region (required for cross-region S3 to S3 sync)

CAVEATS

The --delete option removes files from the destination that don't exist in the source; use with caution. Pattern matching with --include and --exclude is order-dependent. When syncing to local, directories are not created unless they contain files. Sync does not preserve symbolic links.

SEE ALSO

aws-s3(1), aws-s3-cp(1), rsync(1)

> TERMINAL_GEAR

Curated for the Linux community

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95