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

2009-10-04 Thread Jeffrey J. Kosowsky
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 + [[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 BlackBerryreg; 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@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/


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

2009-10-02 Thread Valarie Moore
Thank you for taking the time to help me.

I've now setup my host configuration file, named colombia-jeixav.pl
as follows:

my $user = 'jeixav';
$Conf{ClientNameAlias} = 'localhost';
$Conf{XferMethod} = 'rsync';
$Conf{RsyncShareName} = /home/$user;
$Conf{RsyncClientCmd} = sudo -u $user \$rsyncPath \$argList;
$Conf{RsyncClientRestoreCmd} = sudo -u $user \$rsyncPath \$argList;

The ClientNameAlias remains because the BackupPC server backs up other
computers, so I think I must define either PingCmd or ClientNameAlias
within colombia-jeixav.pl. My hosts file looks like this:

colombia 0 backuppc
colombia-jeixav 0 jeixav
colombia-user2 0 user2

ecuador 0 backuppc
ecuador-user2 0 user2
ecuador-user3 0 user3

I think I found the thread where Jeffrey describes the $_[1] trick:
http://thread.gmane.org/gmane.comp.sysutils.backup.backuppc.general/17274
http://thread.gmane.org/gmane.comp.sysutils.backup.backuppc.general/17280

Given my hosts file, I was thinking that I'd be able to use $_[3] and
have hard-linked files like this:

$Conf{ClientNameAlias} = 'localhost';
$Conf{XferMethod} = 'rsync';
$Conf{RsyncShareName} = /home/$_[3];
$Conf{RsyncClientCmd} = sudo -u $_[3] \$rsyncPath \$argList;
$Conf{RsyncClientRestoreCmd} = sudo -u $_[3] \$rsyncPath \$argList;

Unfortunately, that doesn't seem to work.


--
Come build with us! The BlackBerryreg; 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@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/


[BackupPC-users] Variable in Host Configuration File

2009-10-01 Thread Valarie Moore
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, but using this variable as shown below doesn't work.

$Conf{ClientNameAlias} = 'localhost';
$Conf{XferMethod} = 'rsync';
$Conf{RsyncShareName} = '/home/$user';
$Conf{RsyncClientCmd} = 'sudo -u $user $rsyncPath $argList+';
$Conf{RsyncClientRestoreCmd} = 'sudo -u $user $rsyncPath $argList+';

I am using BackupPC as packaged with Debian 5.0.3 (lenny).


--
Come build with us! The BlackBerryreg; 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@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/


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

2009-10-01 Thread Holger Parplies
Hi,

Valarie Moore wrote on 2009-10-01 16:11:16 + [[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.


Two unrelated remarks:

1. In any case, it should be $argList, not $argList+, as the value is not
   passed through a shell (see remark above $Conf{TarClientCmd} in config.pl
   for an explanation on shell quoting). The default value of RsyncClientCmd
   contains an 'ssh', so in that case $argList needs to be quoted. For 'sudo'
   it should not be (both will work as long as there is, in fact, nothing to
   quote, but you don't want it to break if you change the configuration at
   some point in the future).

2. For backups of localhost (and even more so if RsyncClientCmd does not even
   contain an 'ssh' or equivalent) you don't really need a PingCmd. Then
   again, you might want to keep it to simplify future changes. If you want to
   disable it, you can do so by setting

   $Conf{PingCmd} = '{sub {0}}';

   I'm only mentioning this because *without* a PingCmd, ClientNameAlias
   doesn't do anything anymore, so you could probably drop it (though I'm not
   positive that BackupPC won't try to do a DNS lookup of the name, so you
   might need to keep it after all).

   But this is really more academic than in any way relevant. If in doubt,
   just leave PingCmd and ClientNameAlias as they are.

 I am using BackupPC as packaged with Debian 5.0.3 (lenny).

Which is 3.1.0, in case anyone was wondering.

Regards,
Holger

--
Come build with us! The BlackBerryreg; 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@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/