Bug 6061 - [FMR]: Add an option to only delete files once they expire
Summary: [FMR]: Add an option to only delete files once they expire
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.4
Hardware: x86 Linux
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2009-01-22 01:53 UTC by Craig Phillips
Modified: 2009-01-22 08:47 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Craig Phillips 2009-01-22 01:53:25 UTC
A really nice feature (since rsync is used quite a lot for backups) would be to have a command line option to only delete/prune files when they expire rather than as soon as they are non-existent on the source host.  

For example, using --delete-during will delete any files on the destination host that are no longer on the source host.  However, it might have been a mistake to remove the file on the source host or perhaps its not present due to hardware failure (many scenarios spring to mind).  If a nightly rsync backup is in operation then the files will be lost forever on both the source and destination hosts on the day of deletion.

With an option like:

  --delete-expiry 30

...could ensure files are only deleted/pruned if they no longer exist on the source host AND that their modification time on the destination host is older than (in this example) 30 days.  Exactly like this:

  find /src -type f -mtime +30 -exec rm -f {} \;

One flaw is that you could potentially delete a file on the source host that has already expired on the destination host, but for the majority of files accessed frequently you can be rest assured you will still have a few days to retrieve the file before its gone forever.
Comment 1 Matt McCutchen 2009-01-22 08:47:39 UTC
This approach to keeping old versions of files around is not very general: it handles only deletions, and then only if the file happened to be modified in the 30 days before the deletion (as you noted).  I don't think support for this will be added to rsync.

The recommended approach is to maintain a rotating series of hard-linked backups using --link-dest.  There are several programs that will do this for you, such as rsnapshot.