On Thursday 03 September 2009, Etaoin Shrdlu wrote:
> Apologies if this is a FAQ, but it seems I'm not able to merge the per-host
> config with the general config. In config.pl, I have
>
> $Conf{BackupFilesExclude} = {
> '/' => [ '/proc',
> '/dev',
> '/sys'
> ]
> };
>
> For a specific host, I want to exclude some other directories, so in the
> per- host config file I'm doing
>
> $Conf{BackupFilesExclude}{'/'} = [
> @{$Conf{BackupFilesExclude}{'/'}},
> '/var/spool'
> ];
>
> However, when the backup runs, it seems that the only exclusion is
> /var/spool, instead of '/proc', '/dev', '/sys', '/var/spool' as I would
> expect.
I agree that it should work like that. However, if I'm not mistaken, it seems
that what's written here still applies:
http://osdir.com/ml/sysutils.backup.backuppc.general/2003-10/msg00010.html
As it happens, I was having the same issue in the office, so I changed the
source to "do the right thing". Of course this is a hack, though it seems to
be working for me, but I'm still testing it because it might break something
else. Here is the patch (for rel. 3.0.0 sorry, but I've checked and the
relevant bits have not changed in 3.1 and 3.2):
diff -uNr BackupPC-3.0.0/lib/BackupPC/Lib.pm
BackupPC-3.0.0-patched/lib/BackupPC/Lib.pm
--- BackupPC-3.0.0/lib/BackupPC/Lib.pm 2007-01-29 06:02:48.000000000 +0000
+++ BackupPC-3.0.0-patched/lib/BackupPC/Lib.pm 2009-09-03 20:13:26.000000000
+0100
@@ -328,7 +328,7 @@
# Read host config file
#
if ( $host ne "" ) {
- ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host);
+ ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host,
$bpc->{Conf});
return $mesg if ( defined($mesg) );
$bpc->{Conf} = { %{$bpc->{Conf}}, %$config };
}
diff -uNr BackupPC-3.0.0/lib/BackupPC/Storage/Text.pm
BackupPC-3.0.0-patched/lib/BackupPC/Storage/Text.pm
--- BackupPC-3.0.0/lib/BackupPC/Storage/Text.pm 2007-01-29 06:02:48.000000000
+0000
+++ BackupPC-3.0.0-patched/lib/BackupPC/Storage/Text.pm 2009-09-03
20:13:40.000000000 +0100
@@ -259,7 +259,10 @@
sub ConfigDataRead
{
- my($s, $host) = @_;
+
+ # 3rd argument is existing config to be merged with the per-host config
+
+ my($s, $host, $prevConf) = @_;
my($ret, $mesg, $config, @configs);
#
@@ -270,7 +273,7 @@
push(@configs, $configPath) if ( -f $configPath );
foreach $config ( @configs ) {
- %Conf = ();
+ %Conf = $prevConf?%$prevConf:();
if ( !defined($ret = do $config) && ($! || $@) ) {
$mesg = "Couldn't open $config: $!" if ( $! );
$mesg = "Couldn't execute $config: $@" if ( $@ );
In short, it allows reading the per-host config file with the configuration
already read in the general config in effect, instead of an empty one.
If I've got the program logic right, and that doesn't break anything (which of
course is not granted, as I'm not a real Perl programmer anyway), may I ask
that the change be incorporated in the vanilla BackupPC code?
It doesn't break compatibility with those who are already using the per-host
config to override (rather than add to) the values, but it adds the
possibility to append values, which is very important when you have tens or
hundreds of hosts and almost each of them needs some minor change from the
basic config. Otherwise, you'd end up replicating almost the same things in
each per-host config file, and that is a pain if you later need to change
something in the common bits.
If my patch does it the wrong way, then may I still ask for that to be added
as a feature request?
Thank you for your consideration.
--
D.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
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/
|