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?


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.

  • I am trying to get this to work. For some reason the deletion doesnt go into the rsync_garbage directory. Can you see whats wrong with it? rsync -az --backup-dir='/media/somefolder_a/rsync_garbage' --delete /home/username/a user@ip_address:/media/somefolder_a/ – Hermann Ingjaldsson Nov 13 '17 at 13:00
  • 5
    I don't see the -b option in there. --backup-dir is used to modify the behavior of -b, it doesn't turn -b on by itself. Try -abz. – Michael Kohne Nov 13 '17 at 13:09

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.