Rsync with delete option, but preserve what’s deleted

deletersync

I want to rsync with the delete option so that the folders remain identical copies, also after I have deleted files and folders from the source.

The problem is there might be something on the destination folder that isn't meant to be deleted. In that case, what I would like to happen is that rsync deletion proceeds but the files that are to be removed actually get stored in some garbage folder instead of being removed from the filesystem.

That way I could maintain identical folders without the fear of accidentally overwriting something.

How would it be best to go about achieving such a functionality?

Best Answer

You want the -b option (which causes rsync to backup deleted stuff) combined with the --backup-dir option, which will let you direct WHERE rsync backs things up.

Related Question