aws-s3-sync
Synchronize files between local and S3 locations
TLDR
Sync files in a directory from local to a bucket
Sync files in a directory from a bucket to local
Sync objects between two buckets
Sync local files to S3 while excluding specific files or directories
Sync objects between buckets and delete destination files not in source
Sync to S3 with advanced options (set ACL and storage class)
Sync files to S3 and skip unchanged ones (compare size and modification time)
Display help
SYNOPSIS
aws s3 sync <SOURCE> <DEST> [--delete] [--exclude <pattern>] [--dryrun] [--follow-symlinks] [--size-only] [other options]
PARAMETERS
--acl <value>
Sets the canned ACL (e.g., private, public-read).
--cache-control <value>
Sets the Cache-Control header.
--content-disposition <value>
Sets the Content-Disposition header.
--content-encoding <value>
Sets the Content-Encoding header.
--content-language <value>
Sets the Content-Language header.
--content-type <value>
Sets the Content-Type header (overrides MIME guessing).
--copy-props <value>
Copies specified properties (e.g., metadata, acl).
--delete
Removes files in DEST not present in SOURCE.
Warning: Irreversible!
--dryrun
Shows what would sync without transferring.
--exact-timestamps
Preserves exact timestamps (requires --size-only).
--exclude <pattern>
Excludes files matching pattern (can repeat).
--exclude-from <file>
Excludes patterns from file.
--expires <value>
Sets the Expires header.
--follow-symlinks
Follows symlinks as actual files (default false).
--grant-full-control <value>
Grants full control to grantees.
--grant-read <value>
Grants read access.
--grant-read-acp <value>
Grants read ACL access.
--grant-write-acp <value>
Grants write ACL access.
--include <pattern>
Includes files matching pattern (overrides exclude).
--include-from <file>
Includes patterns from file.
--metadata-directive <value>
COPY|REPLACE for metadata handling.
--no-delete
Explicitly disables --delete (default).
--no-follow-symlinks
Treats symlinks as symlinks (default).
--no-guess-mime-type
Disables MIME type guessing.
--no-progress
Disables progress meter.
--only-show-errors
Shows only errors.
--size-only
Compares by size only, ignores timestamps.
--sse <value>
Server-side encryption algorithm (AES256|aws:kms).
--sse-aws-kms-key-id <value>
Deprecated: Use --sse-kms-key-id.
--sse-c <value>
SSE-C algorithm.
--sse-c-key <value>
SSE-C key (binary).
--sse-c-md5 <value>
SSE-C key MD5 digest.
--sse-kms-key-id <value>
KMS key ID for SSE-KMS.
--storage-class <value>
Storage class (STANDARD|REDUCED_REDUNDANCY|etc.).
--tagging <value>
Sets tags.
--website-redirect <value>
Website redirect location.
DESCRIPTION
The aws s3 sync command synchronizes files and directories between a local filesystem and an Amazon S3 bucket, or between two S3 buckets. It performs a recursive comparison of source and destination, transferring only new, updated, or changed files based on size and modification time. Unlike aws s3 cp, sync is optimized for bulk operations and mirrors directory structures.
Key behaviors include:
- Uploads missing files or those with newer timestamps/sizes from source to dest.
- Downloads changed files when syncing from S3 to local.
- Preserves file metadata where possible.
- Supports exclusions/inclusions via patterns.
It is ideal for backups, deployments, and data mirroring. Use --dryrun to preview changes. By default, deletions in source are not propagated unless --delete is specified. Handles large-scale transfers efficiently with multipart uploads.
CAVEATS
Does not delete by default; use --delete cautiously. Multipart thresholds apply (8MB default). Requires AWS credentials configured. Symlinks handled specially. Large-scale syncs may hit API limits or incur costs.
BASIC EXAMPLES
Local to S3: aws s3 sync ./local/ s3://mybucket/
S3 to local: aws s3 sync s3://mybucket/ ./local/
Two buckets: aws s3 sync s3://bucket1/ s3://bucket2/ --delete
Dry run: aws s3 sync ./local/ s3://mybucket/ --dryrun
PERFORMANCE TIPS
Use --size-only for FAT filesystems. Combine --exclude '*.tmp' --include '*.log'. Increase concurrency via AWS config: max_concurrent_requests.
HISTORY
Introduced in AWS CLI v1 (2013). Enhanced in v2 (2020) with better performance, pagination, and option parity with cp. Remains core for S3 data management.


