BackupPC-users

Re: [BackupPC-users] Variable in Host Configuration File

2009-10-05 01:19:45
Subject: Re: [BackupPC-users] Variable in Host Configuration File
From: "Jeffrey J. Kosowsky" <backuppc AT kosowsky DOT org>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Mon, 05 Oct 2009 01:14:51 -0400
Holger Parplies wrote at about 04:26:45 +0200 on Friday, October 2, 2009:
 > Hi,
 > 
 > Valarie Moore wrote on 2009-10-01 16:11:16 +0000 [[BackupPC-users] Variable 
 > in Host Configuration File]:
 > > I have a host configuration file like this:
 > > 
 > > $Conf{ClientNameAlias} = 'localhost';
 > > $Conf{XferMethod} = 'rsync';
 > > $Conf{RsyncShareName} = '/home/jeixav';
 > > $Conf{RsyncClientCmd} = 'sudo -u jeixav $rsyncPath $argList+';
 > > $Conf{RsyncClientRestoreCmd} = 'sudo -u jeixav $rsyncPath $argList+';
 > > 
 > > I would like to specify the user account jeixav once as a variable, rather
 > > than having it "hardcoded" three times, but I'm don't know how to do this.
 > > Going through the BackupPC's config.pl file, it seems as though the 
 > > variable
 > > called $user should help, [...]
 > 
 > no, it doesn't. Above $Conf {RsyncClientCmd}, the comment starting with "Full
 > command to run rsync on the client machine" does not list a variable $user.
 > For RsyncShareName, there is no substitution at all.
 > 
 > You don't tell us what the "name" of the host is (if the configuration file 
 > is
 > named "foo.pl", then your host name is "foo"). You are using ClientNameAlias
 > to override the host name for ... err ... the ping command (it is not used in
 > RsyncClient{,Restore}Cmd, so it has no other effect), so you've presumably
 > used something descriptive as host name. If your host is actually named
 > "jeixav", you can use $host in RsyncClientCmd and RsyncClientRestoreCmd (but
 > not RsyncShareName).
 > 
 > Depending on what you are exactly trying to achieve, there are several
 > further possibilities.
 > 
 > 1. Avoid three occurrences of the same constant value for aesthetic reasons
 >    or ease of change
 > 
 >    Define a Perl variable in the config file and use it (you won't be able to
 >    use the web based config editor to make changes to the config file,
 >    though):
 > 
 >    my $user = 'jeixav';
 >    $Conf{RsyncShareName} = "/home/$user";
 >    $Conf{RsyncClientCmd} = "sudo -u $user \$rsyncPath \$argList";
 >    $Conf{RsyncClientRestoreCmd} = "sudo -u $user \$rsyncPath \$argList";
 > 
 >    Note the double quotes and the quotation of $-signs for the variables that
 >    are to be interpolated by BackupPC rather than Perl, though.
 > 
 > 2. Reusability of the same config file for several users through hard links
 >    (/etc/backuppc/jeixav.pl, /etc/backuppc/user2.pl, /etc/backuppc/user3.pl
 >    etc. all point to the same file - this is assuming you are using the
 >    relevant user names as "host names" in BackupPC):
 > 
 >    Use Jeffrey's trick of looking for the host name in $_[1] inside the 
 > config
 >    file:
 > 
 >    $Conf{RsyncShareName} = "/home/$_[1]";
 >    $Conf{RsyncClientCmd} = "sudo -u $_[1] \$rsyncPath \$argList";
 >    $Conf{RsyncClientRestoreCmd} = "sudo -u $_[1] \$rsyncPath \$argList";
 > 
 >    The same notes apply as above.
 > 
 > 

As a future feature request, I think it would be good to more broadly
expose such key variables as the hostname (and other similar ones) so
that they can be referred to directly in other variables (as per this
OP's needs for example) without requiring a "kluge" and without
breaking the web configurator.

-- 

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
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>