BackupPC-users

Re: [BackupPC-users] Running a command after backup

2011-02-10 16:21:06
Subject: Re: [BackupPC-users] Running a command after backup
From: Bowie Bailey <Bowie_Bailey AT BUC DOT com>
To: backuppc-users AT lists.sourceforge DOT net
Date: Thu, 10 Feb 2011 16:19:27 -0500
On 2/10/2011 3:41 PM, Jeff Hanson wrote:
> On Thu, Feb 10, 2011 at 3:25 PM, Bowie Bailey <Bowie_Bailey AT buc DOT com> 
> wrote:
>> The only machines I have that make use of that command only have one
>> share, so I can't say from experience.  But reading the docs, that
>> should not happen.  I believe the order should be like this:
>>
>> Run DumpPreUserCmd
>> Run DumpPreShareCmd
>> Dump Share 1
>> Run DumpPostShareCmd
>> Run DumpPreShareCmd
>> Dump Share 2
>> Run DumpPostShareCmd
>> Run DumpPostUserCmd
>>
> Actually that is the problem.  I need the command to run at then end
> of all the jobs, not just individual dumps.
>
> I discovered in the manual that "archive" is a specific xfer method
> which explains why the ArchivePostUserCmd didn't function with rsync.
>
> I may be forced to monitor output from BackupPC_serverMesg to pick out
> active jobs and shut down when there aren't any.

So you are looking for something to run when ALL of the backups are
finished rather that at the end of the backup for each machine?

I don't think there is anything built-in that will do that.  You can
monitor the BackupPC_serverMesg output or monitor the process list for
dump processes.  Note that the output of BackupPC_serverMesg is a valid
Perl datastructure, so you can load it into a Perl script and then read
the data structure rather than trying to parse it manually with a bash
script or something.

And just for the halibut:

#!/usr/bin/perl
$status = `/usr/local/BackupPC/bin/BackupPC_serverMesg status jobs`;
($data) = $status =~ /Got reply: (\%Jobs = \(.*\);)/;
eval $data;
delete $Jobs{' trashClean '};
if (not %Jobs) {
    print "Shutting down now\n";
#    exec('shutdown -h now');
}

Not fully tested, but I think it'll work.  You can run it as-is to test
things.  Once you are sure it is working right, uncomment the shutdown line.

-- 
Bowie

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
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/