How to Sync files, folders in AWS S3?
Syncs directories and S3 prefixes. Recursively copies new and updated files from the source directory to the destination. Only creates folders in the destination if they contain one or more files.
The s3 sync command synchronizes the contents of a bucket and a directory, or the contents of two buckets. Typically, s3 sync copies missing or outdated files or objects between the source and target. However, you can also supply the –delete option to remove files or objects from the target that are not present in the source.
aws s3 sync examples
Syntax : aws s3 sync <source> <target> [–options]
aws s3 sync command
Following example synchronizes the contents of an Amazon S3 prefix named folder in the bucket named bucket1 with the current working directory.
aws s3 sync . s3://bucket1/folder
aws s3 sync delete command
Following example syncs between S3 bucket and local working directory with –delete option. When this is enabled, Files that exist in the destination but not in the source are deleted during sync.
aws s3 sync s3://bucket1/path1 . –delete
aws s3 sync include
Don’t exclude files or objects in the command that match the specified pattern. In below examples , it syncs files ending with .txt
aws s3 sync s3://bucket1/path1 . –include “*.txt”
aws s3 sync verbose
There is no verbose option available in s3 sync command
aws sync s3 buckets
Following example syncs two buckets
aws s3 sync s3://bucket1 s3://bucket2