Tomorrow, John Rouillard wrote:
> On Sun, Nov 04, 2007 at 07:41:51PM -0600, Paul Archer wrote:
>> 9:08pm, John Rouillard wrote:
>>> We tell our users that ~user/bak will be backed up and they can
>>> symbolically link in any directories/files they want backed up.
>>>
>>> To make this work with backuppc and rsync, it means adding the -L or
>>> --copy-links option to the rsync command. However I only want it when
>>> backing up those particular directories (shares) and not say when
>>> backing up / or /usr.
>>>
>>> Does anybody have any ideas for modifying the rsync options on a per
>>> share basis? I was thinking of something similar to the structure for:
>>> $Conf{BackupFilesExclude} = {
>>> [...]
>>> The only workaround I can thing of right now is to define a new host
>>> and override the $Conf{RsyncArgs} in there. However this is less than
>>> optimal since I can't inherit the RsyncArgs from the main
>>> configuration file and augment them, I have to maintain them
>>> separately from the main config file.
>>>
>>> This is also a problem when I have hosts over the wan and I have to
>>> bandwidth limit them. I can't just add in some way --bwlimit=128 I
>>> have to duplicate the entire $Conf{RsyncArgs} variable definition.
>>
>> I haven't tested this, but I believe the order is to source the main config
>> file and then source the config file for the individual host being backed
>> up So you should be able to do something like this:
>>
>> $Conf{RsyncArgs} = [ @$Conf{RsyncArgs}, '--copy-links' ];
>
> You are partly correct. The main config file is sourced first followed
> by the per host config file. However I tried to access
> @$Conf{RsyncShareName} in the per host .pl file and found out the
> %Conf array is undefined. I think what is happening is this:
>
> In BackuPC::Storage::Text
>
> use vars qw(%Conf);
> ...
> sub ConfigDataRead
> {
> my($s, $host) = @_;
> my($ret, $mesg, $config, @configs);
>
> #
> # TODO: add lock
> #
> my $conf = {};
> my $configPath = $s->ConfigPath($host);
>
> push(@configs, $configPath) if ( -f $configPath );
> foreach $config ( @configs ) {
> %Conf = ();
> if ( !defined($ret = do $config) && ($! || $@) ) {
> $mesg = "Couldn't open $config: $!" if ( $! );
> $mesg = "Couldn't execute $config: $@" if ( $@ );
> $mesg =~ s/[\n\r]+//;
> return ($mesg, $conf);
> }
> %$conf = ( %$conf, %Conf );
> }
> ...
>
> @configs is the global config followed by the per host config, but
> notice that %Conf is set to the empty array, and appended to %conf
> overwriting any elements in %conf that are the same as options in
> %Conf. This is how it accumlates the config entries.
>
> Since $conf is a lexically scoped variable it's contents aren't
> available in the "do config" clause. I was thinking of changing the my
> %conf to local %conf so I could get it's values in the config files
> and use:
>
> $Conf{RsyncArgs} = [ @$conf{RsyncArgs}, '--copy-links' ];
>
> but I am not sure of the collateral effects of this change.
>
That does complicate things. Perhaps using Data::Dumper to spit out
everything that's set when the per-machine config.pl is called would reveal
something useful.
It might also be possible to set your own variable(s) in the main config
file that could then be accessed later on.
>> Since you're dealing with Perl, you could probably create a file with a
>> list of slow hosts, read that into a hash (say, %slow_hosts, since I don't
>> like CamelCase)), and then you can say:
>>
>> $Conf{RsyncArgs} = [ @$RConf{RsyncArgs}, '--bwlimit=128' ] if defined
>> $slow_hosts{$host};
>
> I assume $RConf was a typo and you meant $Conf?
>
Exactly.
Paul
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
BackupPC-users mailing list
[email protected]
List: https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/