I am using rsync in a way where I very much want deleted destination files to be backed up, but I very much do not want modified destination files to be backed up. In particular, I want to "shred" deleted files, and the easiest way to do that is to give them a backup prefix and then go through all the files with that prefix after rsync is done and shred them. The reason why it is important for me to only back up deleted files is because I am doing rsync to an s3backer filesystem, and my upload bandwidth is low, so if I back up modified files in addition to deleted ones, then rsync has to write a lot more data to the s3backer filesystem, which make the backup run much more slowly and also costs me more money in s3backer usage fees. The fact that I am using s3backer is also why I want to shred (with -z) the deleted files, because if I overwrite them with nulls, the relevant blocks will be deleted on the s3backer filesystem, thus saving me money in s3backer usage fees.
I added a new flag to rsync to do what I need: --backup-deleted, which backs up deleted files without backing up modified ones. I think this functionality is generally useful enough that it is worth incorporating into the official rsync distribution.
Please note: this introduces a protocol incompatibility, which I have NOT dealt with in my patch, because I don't understand the ins and outs of how this works and I'm pretty sure the rsync maintainers will be able to figure this part out a lot faster and more correctly then I can.
I am attaching to this bug report my patch for adding --backup-deleted support. Thank you for considering my patch.
Created attachment 6169 [details]
patch to add --backup-deleted
Would love to hear your thoughts about this feature. Any chance of getting it in?
Created attachment 6368 [details]
new patch (against rsync 3.0.8) to add --backup-deleted
Thanks! I have adapted your patch for 3.1.0dev and put it in the patches directory. I'm considering including it in the 3.1.0 release.
Some notes on the changes I made in the official patch:
- The option sending was enhanced to send -b to a remote sender, even if the local receiver is using --backup-deleted (making it more backward-compatible). A remote receiver gets both -b and --backup-deleted, which is fine since the latter overrides the former.
- Doc changes need to patch rsync.yo (which generates rsync.1).
Otherwise everything looked great. The changes are nice and simple, which makes me lean toward accepting this as a new option.