Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

amazon web services - AWS S3 sync --delete, removed new files in local

aws s3 sync --delete removed some new files.

For example:

There is a file in the bucket - S3://my-bucket/images/1.jpg

Then, I uploaded a file to the server: 2.jpg

There are 2 files in the server: 1.jpg and 2.jpg

Start running the sync cronjob:

aws s3 sync s3://my-bucket/ ./ --delete
aws s3 sync  ./ s3://my-bucket/ --delete

Why do we add --delete - we want to delete the files in s3 and sync it to the server.

We will upload files to the server and remove the files in s3.

Is there any way to fix it?

question from:https://stackoverflow.com/questions/30591764/aws-s3-sync-delete-removed-new-files-in-local

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

By default, the aws sync command (see documentation) does not delete files. It simply copies new or modified files to the destination.

Using the --delete option deletes files that exist in the destination but not in the source.

So, if your source contains: 1.jpg and 2.jpg and the destination contains 1.jpg, 2.jpg and 3.jpg, then using the --delete option will delete 3.jpg from the destination.

I see that you are running the sync command in both directions. Your first command (that syncs S3 to a local directory) will delete any local files that are not in S3.

If your goal is to copy all local files to S3 and all S3 files to the local directory, without deleting any files, then do not use the --delete option.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...