--delete and --backup - Backup file gets deleted

Marc St-Onge marc.st-onge at canadiansignals.com
Mon Sep 20 23:27:54 GMT 2004


This is not a new bug as I found the behaviour on many version of rsync .
When you use the --delete option combined with --backup, the expected
behaviour is to backup the deleted file on target machine by renaming it
with the backup suffix or with ~ suffix by default.  This works fine but
when you execute the same command a second time, like my cron job does the
next day, the backup file gets deleted forever.  I don't think this was the
original intent but this is the way it works now.

My solution to this has been to modify the source and add an aditional
option which I call --keep-backup.  This was a no-brainer and I would
propose to include it in the next release.  I also added two other options
that I find convenient,  the --delete-suffix and the --delete-dir because I
like to treat deleted files different than archived files that are still in
use but modified from time to time.

All in all, the 3 additional options add a mere 103 lines of new code and
changes to 16 existing lines.  The files modified are: options.c, backup.c,
receiver.c and one declaration in proto.h.

To the rsync team, if you would like to see the changes I propose please let
me know.

Marc St-Onge
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the rsync mailing list