Linux command
aws-s3-sync 命令
网络
需要网络或远程资源。
常用示例
Sync a local directory
aws s3 sync [./local-dir] s3://[bucket-name]/
Download S3 bucket
aws s3 sync s3://[bucket-name]/ [./local-dir]
Sync between two S3 buckets
aws s3 sync s3://[source-bucket] s3://[dest-bucket]
Sync and delete
aws s3 sync [./local-dir] s3://[bucket-name]/ --delete
Sync excluding
aws s3 sync [./local-dir] s3://[bucket-name]/ --exclude "*.log"
Preview sync operation
aws s3 sync [./local-dir] s3://[bucket-name]/ --dryrun
Sync only new files
aws s3 sync [./local-dir] s3://[bucket-name]/ --no-overwrite
说明
aws s3 sync synchronizes directories and S3 prefixes by recursively copying new and updated files from the source to the destination. It only transfers files that are new or have changed, making it efficient for incremental backups and deployments. By default, sync compares file size and last modified time to determine which files need updating. It creates folders in the destination only if they contain files.
参数
- --delete
- Delete destination files that don't exist in the source
- --dryrun
- Display operations that would be performed without executing them
- --quiet
- Suppress all output except errors
- --no-overwrite
- Only transfer files not present at the destination
- --size-only
- Use file size alone to determine if sync is needed (ignore timestamps)
- --exact-timestamps
- Match timestamps exactly when syncing from S3 to local
- --include _pattern_
- Include files matching the pattern
- --exclude _pattern_
- Exclude files matching the pattern from the sync
- --acl _value_
- Set access control list: private, public-read, etc.
- --storage-class _value_
- Specify storage class: STANDARD, STANDARD_IA, GLACIER, etc.
- --source-region _value_
- Source bucket region (required for cross-region S3 to S3 sync)
FAQ
What is the aws-s3-sync command used for?
aws s3 sync synchronizes directories and S3 prefixes by recursively copying new and updated files from the source to the destination. It only transfers files that are new or have changed, making it efficient for incremental backups and deployments. By default, sync compares file size and last modified time to determine which files need updating. It creates folders in the destination only if they contain files.
How do I run a basic aws-s3-sync example?
Run `aws s3 sync [./local-dir] s3://[bucket-name]/` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --delete do in aws-s3-sync?
Delete destination files that don't exist in the source