0

I'm using rsync --remove-source-files --ignore-existing src/ me@server:dest/ to upload new files to the remote server without clobbering/updating any existing files. Any newly uploaded files are removed following this operation.

I would also like files that are already identical on both ends to be removed from src/. That is, the only files remaining in src/ should be files that were not uploaded because a different copy already exists on the server.

Use case: synchronize files from local to server, but 'fail' on operations where a merge conflict exists (manual resolution). Anything that resolved successfully is removed automatically.

This could be solved with multiple commands if necessary (e.g. existing command to upload, a separate command to find identical files and remove from local)

0

Excellent question. rsync is really just used for "one way" mirroring. For your scenario, consider the use of Unison (see https://www.cis.upenn.edu/~bcpierce/unison/) which is a 2-way synchronisation tool. It can handle conflicts nicely, but if you only want to sync in one way, take a look at the --force or --prefer options.

apt install unison if you're on Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.