BackupPC-users

Re: [BackupPC-users] Feature Request

2014-08-28 16:54:21
Subject: Re: [BackupPC-users] Feature Request
From: <backuppc AT kosowsky DOT org>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Thu, 28 Aug 2014 16:49:47 -0400
Les Mikesell wrote at about 13:53:04 -0500 on Thursday, August 28, 2014:
 > On Thu, Aug 28, 2014 at 12:18 PM, Andreas Schnederle-Wagner -
 > Futureweb.at <schnederle AT futureweb DOT at> wrote:
 > >
 > >> Andreas Schnederle-Wagner - Futureweb.at wrote at about 15:41:11 +0000 on 
 > >> Thursday, August 28, 2014:
 > >>  > The Reason we did this ist o avoid custom Config Files for each Host.
 > >>  > We only need to create the Host with name 'ctDIR8' and everything 
 > >> works like a charm ... so only the"hosts" file needs tob e changed when 
 > >> adding/removing Hosts ...
 > >>  >
 > >> You do not need custom Config Files for each host. You could put Perl 
 > >> code in config.pl if you want... and putting custom code in a config file 
 > >> is IMHO a much better option than patching a perl module.
 > >
 > > But as far as I see I cannot access the $HOST Variable within config.pl to 
 > > be used in RsyncShareName - or do I overlook something?
 > >
 > > $Conf{RsyncShareName} = [
 > >   '/tmp'                                //this should be $HOST 
 > > (Case-Sensitive)
 > > ];
 > >
 > 
 > Aren't $client and $host set by the time you need them (as documented
 > to be used in $Conf(RsyncArgs}, $conf{DumpPreUserCmd}, etc.)?
 > 
You are correct that at the time the config file is sourced, the
variable $host (not $HOST) has not yet been set.
I get around this by linking all my config files for the same type of
system to a single master version in the /etc/BackupPC/pc directory.
Then I can recover the host name since it is the name of the file
sourced by 'do' when the config file is read.

For example, I set:
$jhost = $_[1];

This allows me to use a single master config file (with links to it by
host name) that operates differently on different hostnames. 

For example:
if($jhost eq 'machine1') {....} else {...}

This allows me to maintain only a single config file with many
customizations applied to all the systems linked to the file but certain
customizations can be further customized for specific machines using
the above.

To get around other limitations, several of the 'cmd' variables allow
the passing of Perl code which is executed at runtime when all such
variables are set. You have to be careful though, because then you
can't use the $Conf{xxxx} construct, but must use \$bpc->{Conf}{xxxx}.
Other variables similarly may have different names.

For example, when I use rsyncd on a Windows machine, I use code like
this to set RsyncdPasswd by first ssh'ing into the remote host to read
the rsyncd.secrets file rather than having to store it in my config
file which could be a security issue.

        $Conf{DumpPreUserCmd} = ["&{sub { chomp(\$bpc->{Conf}{RsyncdPasswd} = 
`$Conf{SshPath} -q -x -i $BackupPCsshID -l $Conf{RsyncdUserName} 
\$args[0]->{hostIP} cat /etc/rsyncd.secrets`); return(\$? . '\n'); }}"];

Yeah its a hairy hack (and the code I actually use is even hairier
since I do multiple things via DumpPreUserCmd) and of course it may
break under new versions, but it does what I need and it was fun
though painful to figure out...

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
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/

<Prev in Thread] Current Thread [Next in Thread>