Search code examples
s3cmd

s3cmd sync move two buckets into a single bucket


I attempted to do it with the sync command but it tries to delete files from the target bucket that aren't in the source bucket. how can i move two buckets into one bucket with s3cmd?

The situation is that i set it up with the idea that we would use multiple buckets, but the client would like to instead use a single bucket for all files.

when i try it with --skip-existing flag it 6559 files at destination to delete which caused me to panic so i just CTRL-C'd the script. I resync'd the first bucket again to be sure and it says 13 target files were to be deleted, but when i go to the bucket they are still there. is it safe to assume that skip existing will prevent it from deleting the files from the remote bucket that aren't present in the source bucket?


Solution

  • Thanks to @fviard from over at github for answering my queston. copied here is the answer i received:

    By default, the sync don't delete files at destination that are not in the source. It can tell you that in the summary, but it will not do it. Check that you have the following configuration: delete_after = False delete_after_fetch = False delete_removed = False and that you don't use a option on the command line like "--delete-removed".

    Btw, you are not needed to do things in separated commands. Without the "skip-existing", you can do something like that: sync s3://source1/ s3://source2/ s3://source3/ s3://mydestination/

    TLDR; it only deletes the files if you configured it to do so in the config. otherwise the warning message can be ignored.