sync
The aws s3 sync
command is used to synchronize the contents of a bucket and a directory, or two buckets. This command compares the source and the destination, only copying the files that have been modified or added in the source. It's an efficient way to ensure that your local files and S3 bucket have the same content.
Syntax
Sync from Local to S3
aws s3 sync /local/path s3://bucketname/path/
Sync from S3 to Local
aws s3 sync s3://bucketname/path/ /local/path
Sync Between S3 Buckets
aws s3 sync s3://sourcebucket/path/ s3://destinationbucket/path/
Options
source
: The path to the local directory or S3 bucket (e.g.,s3://bucketname/path/
or/local/path
).destination
: The path to the destination directory or S3 bucket.
--delete
: Removes files from the destination that are not present in the source.--exclude
: Exclude files or objects from the command that matches the pattern.--include
: Include files or objects in the command that matches the pattern.
See also the original AWS documentation.