rsync protection filter for backed-up files

Jacob Balazer balazerrsync at umich.edu
Sun Nov 2 23:29:33 GMT 2008


On Sat, Nov 1, 2008 at 8:23 PM, Matt McCutchen <matt at mattmccutchen.net> wrote:
> On Sat, 2008-11-01 at 14:43 -0700, Jacob Balazer wrote:
>> I'm trying to have rsync keep backups of changed and deleted files.
>> Following the examples in the man page, I've set the backup suffix and
>> created a protection filter:
>>
>>   --delete --backup --suffix=~`date +"%Y-%m-%d"` --filter='Pp *~????-??-??'
>>
>> But using this protection filter, not all of my backup files were
>> protected from deletion.  In each subesquent run of rsync, it would
>> try to delete some of my backup files.  The net effect was that the
>> backed up files kept getting renamed with an ever longer string of
>> appended suffixes.
>>
>> I changed the filter to read as follows
>>
>>   --delete --backup --suffix=~`date +"%Y-%m-%d"` --filter='P *~????-??-??'
>>
>> and then it worked correctly.  Is "Pp" filter option as shown in the
>> rsync manual page under the description of --backup a mistake?  Or am
>> I misunderstanding something about the way the protection filter is
>> supposed to work?
>
> The point of the man page was that rsync automatically adds a filter to
> protect your backup files, so you don't have to specify your own unless
> you have other filters that might override the automatically added one.
> The "p" modifier is undesirable for backup files (as you saw), and the
> automatically added rule does not use this modifier; the presence of the
> "p" in the man page is an inaccuracy which I will have fixed.
>
> Your second command is correct, and so would be a command with no
> explicit --filter at all.  The first command is weird, but I can't
> explain why it misbehaved, since I would expect files in extraneous
> destination directories to bypass your filter but then be caught by the
> automatically added filter.  Does anyone see something I'm missing here?
>
> Matt

Thank you, Matt. I think that explains my problem.

In my case, the automatically added protection filter would not be
enough, because it would only cover today's date
(I used  --suffix=~`date +"%Y-%m-%d"`), whereas the backed up files
could be from older dates.

I hope the extraneous "p" can be removed from the man page, to save
someone else the trouble that I had.

Jacob


More information about the rsync mailing list