BackupPC-users

Re: [BackupPC-users] How can I print bash script errors to BackupPC log?

2014-05-21 06:34:10
Subject: Re: [BackupPC-users] How can I print bash script errors to BackupPC log?
From: Alexander Moisseev <moiseev AT mezonplus DOT ru>
To: backuppc-users AT lists.sourceforge DOT net
Date: Wed, 21 May 2014 14:32:03 +0400
21.05.2014 10:30, 李欣 пишет:
> Here is my log in BackupPC:
>
> Output from DumpPreUserCmd: /usr/bin/mysqldump mydatabase > 
> /var/db_backup/database_backup.sql
> Output from DumpPreUserCmd:*mysqldump: Got error: 1045:**  Access denied for 
> user 'root'@'localhost' (using password: NO) when trying to connect
> *DumpPreUserCmd returned error status 512... exiting
>
> How come*mysqldump*can print errors to BackupPC log?
> Can I do the same thing?
>
> Thanks.
>
BackupPC writes both stderr and stdout of external commands to the log.
>
> On 2014/05/20 20:16, Alexander Moisseev wrote:
>> 20.05.2014 15:02, 李欣 пишет:
>>> Hi all,
>>>
>>> How can I print the output of my bash script to BackupPC log file.
>>>
>>> Here is what I tried,
>>> and it does not work.
>>>
>>>      /#!/bin/bash//
>>>      //
>>>      //echo "Hello world"//1>&2;//
>>>      //exit 1;//
>>>      //
>>>      /
>>>
>> BackupPC_serverMesg log Thank you, daemon. I appreciate your effort.
>>
>> http://backuppc.sourceforge.net/faq/BackupPC.html#Step-7:-Talking-to-BackupPC
>>

$Conf{DumpPreUserCmd} = '/tmp/preusercmd.sh';
$Conf{UserCmdCheckStatus} = '1';

where /tmp/preusercmd.sh is your script.

I replaced bash with sh in your script (because I have no bash).
Then I had tested your script and got this in BackupPC log:

2014-05-21 14:06:38 Output from DumpPreUserCmd: Hello world
2014-05-21 14:06:38 DumpPreUserCmd returned error status 256... exiting


Also you do not need to redirect stdout to stderr because BackupPC write to log 
both:
| #!/bin/sh
|
| echo "Hello world";
| exit 1;

--
Alexander

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
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/
<Prev in Thread] Current Thread [Next in Thread>