Re: How to delete files older than X on backup during sync?
On Sun, Nov 9, 2008 at 4:34 PM, Matt McCutchen <firstname.lastname@example.org> wrote:[color=blue]
> On Sun, 2008-11-09 at 03:18 -0500, Matthew Monaco wrote:[color=green]
>> Thomas von Eyben wrote:[color=darkred]
>> > 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…[/color]
>> You can do something like
>> "rsync OPTIONS --rsync-path="find /root-dir/ -mtime +14 -delete ; rsync"
>> SRC DEST"[/color]
> 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.
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…
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: [url]https://lists.samba.org/mailman/listinfo/rsync[/url]
Before posting, read: [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]