Reputation: 106
I have an S3 bucket thats like this:
bucket_name/v1.0.0/file1.js
bucket_name/v1.0.0/file2.js
bucket_name/file3.js
bucket_name/file4.js
I'm trying to copy the files from the v1.0.0 subdirectory to the root directory or bucket, and delete the old files.
aws s3 sync s3://bucket_name/v1.0.0 s3://bucket_name/ --delete --exclude 'v*'
To exclude deleting the version subdirectories, but for some reason this is just deleting the file3.js and file4.js from the root/bucket but its not syncing any files from the v1.0.0 sub directory like i was expecting.
I was expecting to end with:
bucket_name/v1.0.0/file1.js
bucket_name/v1.0.0/file2.js
bucket_name/file1.js
bucket_name/file2.js
Upvotes: 0
Views: 3623
Reputation: 1
I have had a problem similar and later discovered that the folder in S3 had a space after it which was preventing the files from copying
Upvotes: 0
Reputation: 269284
You can copy the files from the v1.0.0
directory to the root directory with:
aws s3 sync s3://bucket_name/v1.0.0/ s3://bucket_name/
The AWS CLI sync
command will never delete the original files. The --delete
option tells it to delete any files in the destination that are not present in the source. For example, let's say you run the sync
once per day and somebody has delete a file from the source during the day. In this situation, the file will also be deleted from the destination by the sync process.
If you wish to move the objects, then you can use:
aws s3 mv s3://bucket_name/v1.0.0/ s3://bucket_name/ --recursive
This will, effectively, copy the objects and then delete the original objects.
Upvotes: 2