This is a discussion on Re: How to delete files older than X on backup during sync? - Tools ; On Sun, 2008-11-09 at 03:18 -0500, Matthew Monaco wrote: > Thomas von Eyben wrote: > > I wish to use rsync to create a backup BUT only keep the files for a > > limited period of time, EG two ...
On Sun, 2008-11-09 at 03:18 -0500, Matthew Monaco wrote:
> Thomas von Eyben wrote:
> > I wish to use rsync to create a backup BUT only keep the files for a
> > limited period of time, EG two weeks.
> > I have not yet been able to figure out how to do this inside rsync
> > (while the backup is being performed) and my understanding of the
> > "--delete" flag is not for this wish.
> > My plan is - unless I find out that it indeed is possible with rsync -
> > to make a cronjob removing files older than X in the folder containing
> > the backups…
> You can do something like
> "rsync OPTIONS --rsync-path="find /root-dir/ -mtime +14 -delete ; rsync"
> SRC DEST"
If you count the two-week period from the mtime of the file, then
backups of really old files will be deleted as soon as they are saved.
I think it would make more sense to count from the time the backup file
is saved. To do that, use a separate --backup-dir each day (e.g.,
--backup-dir=../backups/$(date +%Y-%m-%d) ) and simply delete each
backup dir as a whole when it becomes two weeks old.
The only disadvantage is that with multiple backup dirs, it becomes less
trivial to find backups of a particular path, but it would be easy to
write a script to help with this.
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html