The AWS CLI sync command compares a local directory with an S3 location and transfers only new or changed files. It is useful for backing up local data to a bucket. section 7.3
$ aws s3 sync $path s3://awsinaction-$yourname/backup
Use this command pattern to synchronize a local folder with a backup prefix in S3, replacing the placeholders with your values. section 7.3
Back up a folder
Choose a local folder, preferably smaller than 1 GB to limit waiting time and Free Tier usage. Run sync to upload it to the bucket's /backup location; transfer time depends on folder size and internet speed. section 7.3
A basic backup workflow includes:
- Create or select an S3 bucket. section 7.3
- Synchronize the local folder with the bucket's backup prefix. section 7.3
- Restore files separately by recursively copying the S3 backup to another local folder. section 7.3
