Reputation: 905
I have 2 buckets, Bucket A and Bucket B. Bucket A contains Javascript files and bucket B contains a mix of javascript and other file types. I am trying to do a sync of only JS files from bucket A to B.
I am using the following:
aws s3 sync s3://bucket-a s3://bucket-b --delete --exclude "*" --include "*.js"
I was assuming that this will leave bucket B with an exact copy of all of the js files. However the above command will start deleting all of the non js files in Bucket B.
When I run the following command:
aws s3 sync . s3://bucket-b --delete --exclude "*" --include "*.js"
With the current directory containing a copy of bucket A, bucket B will have the same js files as bucket A and non js files will not be affected.
Why is this command functioning differently when syncing local to bucket compared to bucket to bucket?
EDIT: Added CLI input/output to reproduce problem.
Darrrens-MBP:testFolder darren$ aws --version
aws-cli/1.7.4 Python/2.7.9 Darwin/14.4.0
Darrrens-MBP:testFolder darren$ aws s3 ls s3://tmp-test-bucket-a
2015-09-01 11:40:44 2 test1.js
2015-09-01 11:40:43 2 test2.js
Darrrens-MBP:testFolder darren$ aws s3 ls s3://tmp-test-bucket-b
2015-09-01 11:39:32 2 test1.js
2015-09-01 11:39:34 2 test2.js
2015-09-01 11:39:34 3 test3.php
Darrrens-MBP:testFolder darren$ ls
test1.js test2.js
Darrrens-MBP:testFolder darren$ aws s3 sync . s3://tmp-test-bucket-b --delete --exclude "*" --include "*.js"
Darrrens-MBP:testFolder darren$ aws s3 sync s3://tmp-test-bucket-a s3://tmp-test-bucket-b --delete --exclude "*" --include "*.js"
delete: s3://tmp-test-bucket-b/test3.php
copy: s3://tmp-test-bucket-a/test2.js to s3://tmp-test-bucket-b/test2.js
copy: s3://tmp-test-bucket-a/test1.js to s3://tmp-test-bucket-b/test1.js
Upvotes: 2
Views: 4740
Reputation: 434
If I understand the problem correctly,--delete deletes files that exist in the destination but not in the source during sync, which are the ones you exclude.better use aws s3 cp instead of aws s3 sync.
Upvotes: 1