Exclude multiple folders using AWS S3 sync

前提是你 提交于 2019-12-03 10:23:32
Ashish Karpe

At last this worked for me:

aws s3 sync  s3://xxxx-app-file-storage-bucket-prod-env   s3://xxxx-app-file-storage-bucket-test-env --exclude 'customers/*'  --exclude 'orders/*'  --exclude 'reportTemplate/*'  

Hint: especially you have to enclose your wildcards and special characters in single or double quotes to work properly, below are example of matching characters. for more information regarding S3 commands, check it in amazon here.

*: Matches everything
?: Matches any single character
[sequence]: Matches any character in sequence
[!sequence]: Matches any character not in sequence

For those who are looking for sync some subfolder in a bucket, the exclude filter applies to the files and folders inside the folder that is be syncing, and not the path with respect to the bucket, example:

aws s3 sync s3://bucket1/bootstrap/ s3://bucket2/bootstrap --exclude '*' --include 'css/*'

would sync the folder bootstrap/css but not bootstrap/js neither bootstrap/fonts in the following folder tree:

bootstrap/
├── css/
│   ├── bootstrap.css
│   ├── bootstrap.min.css
│   ├── bootstrap-theme.css
│   └── bootstrap-theme.min.css
├── js/
│   ├── bootstrap.js
│   └── bootstrap.min.js
└── fonts/
    ├── glyphicons-halflings-regular.eot
    ├── glyphicons-halflings-regular.svg
    ├── glyphicons-halflings-regular.ttf
    └── glyphicons-halflings-regular.woff

That is, the filter is 'css/*' and not 'bootstrap/css/*'

More in https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!