I have a local directory that I would like to synchronize with an S3 bucket.
I have two specific requirements:
- If local file is the same as the remote, do not re-transfer it to the bucket.
- If some files or directories exist in the bucket but do not exist on local, delete them. Basically the bucket should mirror the local copy and not vice-versa.
I looked into s3cmd sync
command, but unfortunately requirement 2 is not fulfilled. If files exists in the bucket but not on local copy, they will be copied to the local instead of being deleted.
Best Answer
I finally found an answer by looking further in the s3cmd manual. It turns out that there are options that alter the behaviour of the commands. One option is
--delete-removed
which alterssync
in the way I want: