Amazon web services 使用AWS S3 sync排除多个文件夹
如何在使用aws s3 syn时排除多个文件夹 我试过:Amazon web services 使用AWS S3 sync排除多个文件夹,amazon-web-services,amazon-s3,s3cmd,Amazon Web Services,Amazon S3,S3cmd,如何在使用aws s3 syn时排除多个文件夹 我试过: # aws s3 sync s3://inksedge-app-file-storage-bucket-prod-env s3://inksedge-app-file-storage-bucket-test-env --exclude 'reportTemplate/* orders/* customers/*' 但它仍在为文件夹“客户”执行同步 输出: copy: s3://inksedge-app-file-storage-b
# aws s3 sync s3://inksedge-app-file-storage-bucket-prod-env s3://inksedge-app-file-storage-bucket-test-env --exclude 'reportTemplate/* orders/* customers/*'
但它仍在为文件夹“客户”执行同步
输出:
copy: s3://inksedge-app-file-storage-bucket-prod-env/customers/116/miniimages/IMG_4800.jpg to s3://inksedge-app-file-storage-bucket-test-env/customers/116/miniimages/IMG_4800.jpg
copy: s3://inksedge-app-file-storage-bucket-prod-env/customers/116/miniimages/DSC_0358.JPG to s3://inksedge-app-file-storage-bucket-test-env/customers/116/miniimages/DSC_0358.JPG
这终于对我起了作用:
aws s3 sync s3://my-bucket s3://my-other-bucket \
--exclude 'customers/*' \
--exclude 'orders/*' \
--exclude 'reportTemplate/*'
提示:必须将通配符和特殊字符括在单引号或双引号中才能正常工作。下面是匹配字符的示例。有关S3命令的更多信息,请登录
对于正在查找同步存储桶中某个子文件夹的用户,排除筛选器将应用于要同步的文件夹中的文件和文件夹,而不是与存储桶相关的路径,例如:
aws s3 sync s3://bucket1/bootstrap/ s3://bucket2/bootstrap --exclude '*' --include 'css/*'
将同步以下文件夹树中的bootstrap/css而不是bootstrap/js或bootstrap/font文件夹:
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
也就是说,过滤器是“css/*”而不是“bootstrap/css/*”
在Windows命令提示符下,只有双引号起作用,所以在通配符周围使用“”,例如:
aws s3 sync s3://bucket-1/ . --exclude "reportTemplate/*" --exclude "orders/*"
单引号在Windows 10上不起作用(通过--dryrun选项测试)。当我们有多个文件夹结构时,我使用了一种不同的方式。将“**”与--include一起使用 命令:
aws s3同步s3://$SOURCE\u BUCKET/dir1/dir2/s3://$TARGET\u BUCKET/dir1/dir2/--包括“***/***'我认为您需要为每个模式使用--exclude选项,即:
--排除'reportTemplate/*'--排除'orders/*'--排除'customers/*'
”。将整个内容放在这样的引号中很可能会认为整个内容是一个单一的模式。Amazon提供了AWS CLI,这是一个用于与AWS交互的命令行工具。使用AWS CLI,整个过程只需不到三秒钟:$AWS s3 sync s3:///例如AWS s3 sync s3://s3.AWS-CLI.demo/photos/office~/Pictures/work
aws s3 sync s3://bucket-1/ . --exclude "reportTemplate/*" --exclude "orders/*"