BackupPC-users

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

2011-02-10 20:34:56
Subject: Re: [BackupPC-users] Running a command after backup
From: Jeff Hanson <jhansonxi AT gmail DOT com>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Thu, 10 Feb 2011 20:32:36 -0500
On Thu, Feb 10, 2011 at 4:19 PM, Bowie Bailey <Bowie_Bailey AT buc DOT com> 
wrote:
>
> #!/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.
>

That seemed to work but would require some changes to sudoers so that
the backuppc account could perform the halt.  Easy to do but I came up
with a simple solution based on my previous attempt that seems to
work.

DumpPreUserCmd:  touch /var/lib/backuppc/dump-start.flg

DumpPostUserCmd:  mv /var/lib/backuppc/dump-start.flg
/var/lib/backuppc/dump-end.flg

/etc/cron.d/backuppc-halt:
*/5 * * * * root [ -f /var/lib/backuppc/dump-end.flg ] && sleep 3m &&
[ ! -f /var/lib/backuppc/dump-start.flg ] && rm
/var/lib/backuppc/dump-end.flg && [ "$(/usr/bin/who)" = "" ] &&
/sbin/halt

Description:
Check every 5min for the dump end flag file.  If found, wait 3min then
check for the dump start flag file.  If it is not found then all jobs
have finished so remove the end flag file, check for active users, if
none then halt system.


The only issue is the length of the time window between the end of one
dump and the start of the next.  The 3 minute delay seems to be enough
for my system.

------------------------------------------------------------------------------
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/