How to delete files older than X on backup during sync?

Matt McCutchen matt at
Sun Nov 9 21:01:52 GMT 2008

Matthew, please remember to CC rsync at .

On Sun, 2008-11-09 at 15:46 -0500, Matthew Monaco wrote:
> You could use touch to update all of the files in your backup-dir.  Then
> use my original suggestion to delete files that are older than two weeks.

I assume you mean, touch only the destination files corresponding to
source files that still exist (and you'd get that list from itemize
output)?  That would work, but it loses the mtimes of the files, which
will make the rsync quick check fail and may make the backup less
useful.  Using the atime instead would work nicely provided that the
atime field isn't being used for anything else and the destination
filesystem is mounted noatime.


> Matt McCutchen wrote:
> > On Sun, 2008-11-09 at 19:03 +0100, Thomas von Eyben wrote:
> >> Actually, I think I need to be a little more specific (now I think
> >> about it): I only want to keep the files that are deleted on the
> >> source for the additional period of two weeks.
> >>
> >> So I want to keep the back up identical to the source, just not
> >> deleting files in the backup that are deleted in the source (should be
> >> fairly easy with rsync ;-) BUT I  only want to keep these
> >> deleted-on-source files for an additional period of two weeks…

More information about the rsync mailing list