BackupPC-users

Re: [BackupPC-users] How do I configure DumpPreUserCmd to have multiple commands

2011-08-05 10:12:15
Subject: Re: [BackupPC-users] How do I configure DumpPreUserCmd to have multiple commands
From: Rory Toma <rory AT ooma DOT com>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Fri, 05 Aug 2011 07:08:52 -0700
The ls command was to debug an issue that went away when I put in the ls 
command.

I was creating a snapshot then backing up said snapshot. However, I kept 
getting "Stale NFS errors". When I put in the ls to see what was going 
on, the problem went away.

On 8/5/11 6:01 AM, Holger Parplies wrote:
> Hi,
>
> Jeffrey J. Kosowsky wrote on 2011-08-04 01:37:23 -0400 [Re: [BackupPC-users] 
> How do I configure DumpPreUserCmd to have multiple?commands]:
>> Rory Toma wrote at about 18:15:32 -0700 on Wednesday, August 3, 2011:
>>   >  [...]
>>   >  In my case, I want to do something like:
>>   >
>>   >  rsh -n<machine>  <command>; rsh -n<machine>  command ; ls<sharename>;
>>   >  ls<sharename2>
>>
>> As the config.pl inline documentation *clearly* states:
>> # Note: all Cmds are executed directly without a shell, so the prog name
>> # needs to be a full path and you can't include shell syntax like
>> # redirection and pipes; put that in a script if you need it.
>>
>> Chaining together multiple commands separated by a ";" is a *shell*
>> feature.
>>
>> So either package it all into an explicit shell command directly, e.g.,
>>     bash -c "rsh -n<machine>  <command>; rsh -n<machine>  command ; \
>>     ls<sharename>; ls<sharename2>"
> I'm not sure that works. As you know, *quoting* is also a shell feature. Now,
> bash just *might* reparse its command line arguments, remove quotes, and
> recombine arguments, but I don't feel that is very likely, because whitespace
> between arguments will have been lost and can only be replaced by single 
> blanks
> (which may or may not be what was previously there). Quoting is simply
> something that needs to be done before invoking bash to get it right. However,
> there might be a special case for the argument to -c starting with a quote.
>
> So, if bash *doesn't* recombine arguments, according to the man page, only the
> first one will be interpreted as a command ('"rsh'). This would mean that
> there would in fact be no way to make this work without changing the BackupPC
> code.
>
> You *could*, however, use Perl code to achieve the same thing.
>
>       $Conf{DumpPreUserCmd} = '&sub{ system ("...");}';
>
> where "..." is your 'rsh; rsh; ls; ls' sequence (system() uses a shell if it
> finds shell metacharacters - such as a semicolon - in the command).
>
> Disclaimer: both that the 'bash -c' version doesn't work and that the Perl
> version does are untested.
>
>> Or package it all together into a shell shell secret
> That is probably meant to read "shell script" ;-). That is without doubt the
> most simple solution (and the one recommended in the config.pl comment).
>
> Note also that "rsh" (do you really mean "rsh" and not "ssh"!?) *does*
> execute a shell (and accept the command to be run in an arbitrary amount of
> command line arguments), so you could also use something like
>
>       rsh -n<machine>  <command1>;<command2>
>
> to run both<command1>  and<command2>  on<machine>  (this also means your
> example above should, in fact, have worked, except for running the second
> 'rsh' command and the 'ls'es on<machine>, which may or may not be meaningful).
> I don't quite understand the point in the 'ls' commands, which only seem to
> list the directory contents to the log file (which might be useful for
> debugging, but shouldn't make a difference for backup operation, unless the
> second 'ls' returns an error exit status ...).
>
> Hope that helps.
>
> Regards,
> Holger
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos&  much more. Register early&  save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> 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/


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
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/