Bacula-users

[Bacula-users] How to properly escape Linux shell commands for ClientRunBeforeJob?

2009-02-13 09:24:08
Subject: [Bacula-users] How to properly escape Linux shell commands for ClientRunBeforeJob?
From: Foo <bfoo33 AT yahoo.co DOT uk>
To: "bacula-users AT lists.sourceforge DOT net" <bacula-users AT lists.sourceforge DOT net>
Date: Fri, 13 Feb 2009 15:21:48 +0100
Hi,

I'm trying to run the following command before a backup:

svnadmin --quiet dump /var/svnrepo >/tmp/svnrepo_backup.svn_dump; gzip -9  
/tmp/svnrepo_backup.svn_dump

and 'rm -f /tmp/svnrepo_backup.svn_dump.gz' after the job. When executing  
the above on the shell it works fine.

So I added in the job definition of the machine:

ClientRunBeforeJob = "svnadmin --quiet dump /var/svnrepo  
>/tmp/svnrepo_backup.svn_dump; gzip -9 /tmp/svnrepo_backup.svn_dump"
ClientRunAfterJob = "rm -f /tmp/svnrepo_backup.svn_dump.gz"

This fails with:

  ClientRunBeforeJob: svnadmin: invalid option character: 9
  ClientRunBeforeJob: Type 'svnadmin help' for usage.
  Error: Runscript: ClientRunBeforeJob returned non-zero status=1.  
ERR=Child exited with code 1

Obviously the command needs some escapes lest svnadmin think all the line  
is arguments for it. So I peruse the manual and find the '>' needs  
escaping.

But when I do that (or break up the svnadmin and gzip commands into two  
ClientRunBeforeJob lines), the whole svn dump will be done to standard  
out, which in short order fills up the bconsole log and since the job  
output is mailed, kills bsmtp and gets me blacklisted on the mail gateway  
for DoS-ing it :) Canceling the job doesn't stop the flood, only killing  
the bacula-fd on the SVN machine does after a while.

Does anyone know how to properly escape the above? I could probably use a  
local shell script as a single command instead, but would like to know how  
to do proper escaping for future use.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users