AWS S3 Sync Command

TL;DR

aws s3 sync my-documents s3://my-s3-bucket

Running this command prompts AWS to compare the files in “my-documents” with those in “my-s3-bucket”. Any new or updated files in “my-documents” are then copied to “my-s3-bucket”.

You might occasionally need to remove unused files from your local system, even though they’re still available in S3 buckets. The default aws s3 sync command only syncs new and updated files. In such cases, you can use the --delete option to also remove files from the S3 bucket.

There are various command line options available to modify the default behavior of the aws s3 sync command. Here are some useful options that you can use according to your needs:

Option Description
–delete Removes files from the destination that are not in the source.
–exact-timestamps Uses exact timestamps when comparing files.
–exclude Excludes specific files from being synced (e.g., –exclude “*.txt”).
–include Includes specific files in the sync (used with –exclude).
–dryrun Shows what files would be synced without actually performing the sync.
–acl Sets the Access Control List (ACL) for synced files (e.g., –acl public-read).
–storage-class Sets the storage class for synced files (e.g., –storage-class STANDARD_IA).
–sse Enables server-side encryption for synced files.
–follow-symlinks Follows symbolic links when syncing files.
–no-follow-symlinks Does not follow symbolic links when syncing files.

The aws s3 sync command is incredibly powerful and can save you a lot of time, especially when working with large amounts of data. It ensures that your local files and your S3 files are always identical.

Feedback