BackupPC-users

Re: [BackupPC-users] why are excludes sent to rsync when none are present in the config file?

2011-09-19 22:33:48
Subject: Re: [BackupPC-users] why are excludes sent to rsync when none are present in the config file?
From: Holger Parplies <wbppc AT parplies DOT de>
To: Adam Monsen <haircut AT gmail DOT com>
Date: Tue, 20 Sep 2011 04:31:32 +0200
Hi,

Adam Monsen wrote on 2011-09-18 19:29:00 -0700 [[BackupPC-users] why are 
excludes sent to rsync when none are present in the config file?]:
> Anyone know why excludes might be sent to rsync when none are
> specified in my config file?

yes.

> BackupFilesOnly has one key, '*', pointing to an array with several
> values (/etc, /home, /opt/backup/stage/*/active,
> /opt/backup/stage/other, and a few more). BackupFilesExclude is set to {}.
> 
> But in the XferLOG, I see
> 
> [...]
>   Sent include: /etc
>   Sent include: /home
>   Sent include: /opt
>   Sent include: /opt/backup
>   Sent include: /opt/backup/stage
>   Sent include: /opt/backup/stage/*
>   Sent include: /opt/backup/stage/*/active
>   Sent include: /opt/backup/stage/other
> [...]
>   Sent exclude: /*
>   Sent exclude: /opt/*
>   Sent exclude: /opt/backup/*
>   Sent exclude: /opt/backup/stage/*
>   Sent exclude: /opt/backup/stage/*/*
>   Sent exclude: /home/*
>   Sent exclude: /home/*/*
> [...]
> Are these excludes expected?

Yes. rsync has no 'include directories ... only' semantics. To get rsync to
backup /etc and /home *only*, for example, BackupPC needs to generate options
like '--include=/etc --include=/home --exclude=/*' so that *only* /etc and
/home (with contents) are included. For directories deeper down the tree, this
becomes more complicated. To backup only the directory /opt/backup, we need
something like
'--include=/opt --exclude=/* --include=/opt/backup --exclude=/opt/*'. This
should explain the includes and excludes you are seeing.

Note that one include is *not* handled correctly by BackupPC:
/opt/backup/stage/*/active - wildcards within the BackupFilesOnly patterns
were obviously not anticipated. While the generated options work for the
directories themselves, they have the side effect of making your
/opt/backup/stage/other include *not* work correctly (due to the generated
exclude /opt/backup/stage/*/*, which matches and thus excludes the files
within /opt/backup/stage/other). I'll see if I can find the time to write a
patch, but I'm not promising anything. I'd like to add that this might be
rather complicated and only catch one single rare corner case. It would be
more worthwhile if we could find out what other corner cases there are that
are not handled correctly.

> I just discovered this problem when I was trying to restore a file in
> /opt/backup/stage/other.

Sorry about that. But it *does* prove again that you should test your backups,
in particular, have a look if your includes are working properly!

> AHA, adding the following entry to BackupFilesOnly '*' worked:
> 
>   /opt/backup/stage/other/*
> 
> Now that directory is backed up. But I don't understand why. :)

You probably do now. BackupPC should really have generated this. By adding it
manually, you corrected this oversight, ***but*** only for the immediate
directory contents. If I read the code correctly, BackupPC will now generate
an *exclude* /opt/backup/stage/other/*/*, meaning any content in any
*subdirectories* will again be excluded (so, this is a second corner case).
Please check if this is relevant for you! As almost suggested elsewhere, the
correct workaround would be to set

        $Conf {RsyncArgsExtra} = [ '--include' => '/opt/backup/stage/other/*' ];

(hmm, please test that - the order of includes/excludes would be important in
this case, i.e. '--include=/opt/backup/stage/other/*' would need to be passed
*before* the '--exclude=/opt/backup/stage/*/*' to have any effect; this is
also the reason we can't trick BackupFilesExclude into handling the *in*clude
for us - it would be appended after the internally generated excludes).
Note, though, that this setting applies to all shares (you only seem to have
'/', so that's probably ok), and that this variable first appeared in BackupPC
3.2.0, so it will *not* work, if you are using an earlier version (append to
RsyncArgs in that case).

Hope that helps.

Regards,
Holger

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/