BackupPC-users

Re: [BackupPC-users] General questions about the background queue and link commands.

2011-02-03 14:04:29
Subject: Re: [BackupPC-users] General questions about the background queue and link commands.
From: "Jeffrey J. Kosowsky" <backuppc AT kosowsky DOT org>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Thu, 03 Feb 2011 14:02:33 -0500
Robin Lee Powell wrote at about 09:30:17 -0800 on Thursday, February 3, 2011:
 > On Thu, Feb 03, 2011 at 09:22:00AM -0800, Robin Lee Powell wrote:
 > > OK, so the question becomes, how do I monitor for general backup
 > > queue problems?  I've had situations where something gets stuck,
 > > like a nightly job, and the queue gets backed up, and I want to
 > > detect that.
 > > 
 > > I guess if I could get access to the backup age that's on the host
 > > summary, from a script, that would do.
 > 
 > Got it; short version below, remind me to post after the real script
 > is done:
 > 
 > for num in $(sudo -u backuppc BackupPC_serverMesg status hosts | sed 
 > 's/},[{"]/\n/g' | grep lastGoodBackupTime | sed 's/.*"lastGoodBackupTime" => 
 > "//' | sed 's/".*//' )
 > do
 >   if [ $[$(date +%s) - $num] -gt 77760 ]
 >   then
 >     echo "needs backup"
 >   fi
 > done

OK I couldn't resist...
I tried your script and unfortunately it doesn't say *which* host
needs backup. Also, it uses 3 seds and a grep... there has to be a
better way...

So here is my "1-liner"
(set -- $(sudo -u backuppc /usr/share/BackupPC/bin/BackupPC_serverMesg status 
hosts | sed -ne 's/.*("\([^"]*\)" => {[^}]*"lastGoodBackupTime" => 
"\([0-9]*\)".*/\1 \2/pg'); while [ "$1" ]; do if [ $[$(date +%s) - $2] -gt 
77760 ]; then echo "$1 needs backup"; fi; shift; shift; done)


Seems to work on my setup but I haven't tested it too much...

It will break if there are white spaces in the host name though I'm
not sure that actually happens in real life -- if it does you can
always use IFS tricks like:

(IFS=$'\n'; set -- $(sudo -u backuppc 
/usr/share/BackupPC/bin/BackupPC_serverMesgstatus hosts | sed -ne 
's/.*("\([^"]*\)" => {[^}]*"lastGoodBackupTime" => "\([0-9]*\)".*/\1\n\2/pg'); 
while [ "$1" ]; do if [ $[$(date +%s) - $2] -gt 77760 ]; then echo "$1 needs 
backup"; fi; shift; shift; done)

This will only fail if there is a newline in the hostname which I
imagine should never happen.

Hope that helps

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
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/