Bacula-users

Re: [Bacula-users] Run scripts fails

2011-12-27 10:15:45
Subject: Re: [Bacula-users] Run scripts fails
From: Konstantin Khomoutov <flatworm AT users.sourceforge DOT net>
To: Sebastien Douche <sdouche AT gmail DOT com>
Date: Tue, 27 Dec 2011 19:13:44 +0400
On Tue, 27 Dec 2011 14:55:48 +0100
Sebastien Douche <sdouche AT gmail DOT com> wrote:

> Hi,
> The command is not launched w/o error in the log. My config file:
> 
> Job {
>   Name = "BackupDagobah"
>   JobDefs = "SA1Job"
>   FileSet = "Wordpress Set"
>   Client = dagobah-fd
>   RunScript {
>     Command = "/usr/bin/mysqldump --user=wordpress --password=XXX
> wordpress > /srv/wordpress/db/wordpress.sql"
>     RunsWhen = Before
>   }
> 
> But the director display something when it parses the config file:
> 
> $ sudo /usr/sbin/bacula-dir -f -d -c /etc/bacula/bacula-dir.conf -t
> bacula-dir: dird_conf.c:1860-0 runscript cmd="/usr/bin/mysqldump
> --user=wordpress --password=XXX wordpress >
> /srv/wordpress/db/wordpress.sql" type=|
> 
> Any ideas?
I suspect the problem is that running an internal command does not have
shell semantics, or, to put differently, the call does not go through
the shell.

What that means, is when you run
cmd >file
from within a shell (or in a shell script, which is essentially the
same) the shell opens the file "file" and then runs the "cmd" command
with its stdout redirected to the file descriptor assotiated with that
opened file; after the command exits, the shell closes the file.

But bacula just calls something like execv(2) on your arguments,
so your mysqldump binary gets those ">" and "/srv/...." arguments
literally and has no idea what to do with them.

So either use something like

Command = "/bin/sh -c '/usr/bin/mysqldump --user=wordpress --password=XXX 
wordpress > /srv/wordpress/db/wordpress.sql'"

or create a shell script and specify its name.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>