Command
aws s3 sync ./local-dir s3://my-bucketExplanation
Compares files between a local directory and an S3 bucket, uploading or downloading only changed files.
Common Use Cases
- •Backing up local directories to S3
- •Deploying static websites
- •Restoring files from S3 to local
Best Practices
- ✓Use `--dryrun` first to preview changes
- ✓Include `--delete` to remove files not present in the source
Common Mistakes to Avoid
- ⚠Forgetting the trailing slash, causing incorrect directory structure
- ⚠Using sync in the wrong direction (local-to-remote or vice versa)
Troubleshooting
Problem: Missing files
Solution: Use `--exact-timestamps` for precise comparison.
Problem: Slow performance
Solution: Add `--size-only` to skip timestamp checks.
Examples
Upload local directory to S3
aws s3 sync ./local-dir s3://my-bucketDownload bucket contents locally
aws s3 sync s3://my-bucket ./local-dir