Bacula-users

Re: [Bacula-users] FW: Client last backup time report

2013-11-19 01:09:53
Subject: Re: [Bacula-users] FW: Client last backup time report
From: Juraj Sakala <juraj.sakala AT gmail DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Tue, 19 Nov 2013 07:06:49 +0100
I do similar stats with this script. Script searches for clients those
have no successful backup for last 5 days:

#!/bin/bash
CURDATE=`date +%s`
# DELTA is 5 days
DELTA=432000
CHECKDATE=$((CURDATE-DELTA))
CHECKDATE2=`date -d @$CHECKDATE "+%Y-%m-%d %H:%M:%S"`

### Read client list via bcopnsole
/usr/sbin/bconsole -c /etc/bacula/bconsole.conf <<END_OF_DATA
@output /tmp/bcheck_backup_status.out
.clients
quit
END_OF_DATA

### Remove tahat is not needed
sed -i -r '/(bacula-fd|quit|\.clients|messages)/d'
/tmp/bcheck_backup_status.out

### Database query
for CLIENT in `cat /tmp/bcheck_backup_status.out`; do
echo "SELECT Job.JobStatus,Job.EndTime FROM bacula.Client,bacula.Job
WHERE Client.Name='$CLIENT' AND Client.ClientId=Job.ClientId AND
Job.StartTime > '$CHECKDATE2' ORDER BY Job.Sta
rtTime;" | /usr/bin/mysql -s -u bacula /tmp/$CLIENT.sqlres

### If no backup or only failed backups are in database for last 5 days
send email
if [ `cat /tmp/$CLIENT.sqlres | wc -l` -eq 0 ] || [ "`grep T
/tmp/$CLIENT.sqlres`" == "" ]; then
    echo "$CLIENT" >> /tmp/bcheckjobstatus.mail
fi
done

### If we have client without successfull backup send mail
if [ -f /tmp/bcheckjobstatus.mail ]; then
sed -i '1i From: bacula AT backup DOT fm' /tmp/bcheckjobstatus.mail
sed -i '2i To: root' /tmp/bcheckjobstatus.mail
sed -i '3i Subject: Bacula clients without successful backup'
/tmp/bcheckjobstatus.mail
sed -i '4i \ ' /tmp/bcheckjobstatus.mail
sed -i '5i Clients without successful backup for 5 days:'
/tmp/bcheckjobstatus.mail
cat /tmp/bcheckjobstatus.mail | /usr/sbin/sendmail -f bacula AT backup DOT fm 
root
fi

### Cleanup
rm -f /tmp/bcheck_backup_status.out /tmp/*.sqlres /tmp/bcheckjobstatus.mail




On 11/15/2013 11:11 PM, Robyn wrote:
> I need to create a report with the last time a good backup was run of each
> client. 
> 
> We are looking for anyone who has not backed up recently, so it would be
> nice if the report could be set for clients that have not had a successful
> backup in 1 week, or even a variable amount of time.
> 
> I am assuming this would be SQL. Grepping (or anything else) Bacula's 'List
> Jobs' would not work, since if a client has not even started a backup it
> would not be listed there. (Our backups are kicked off by remotely calling a
> script on each client that starts the FD. We have several 'waves' of backups
> when departments are not here or would be least affected by the backup.)
> 
> We envision the report being something like:
> 
>  
> 
> Name         Last Backup      F/D/I  JobFiles   JobBytes JobStatus
> 
> COMPUTER1    2013-11-06 23:59   I          29    129,056     T
> 
> LAPTOP2      2013-10-20 10:30   D          17     89,423     T
> 
> COMPUTER2    2013-10-19 17:05   I           0          0     E
> 
>  
> 
> Anyone else doing something like this, or can point me to some examples?
> 
>  
> 
> Thanks in advance
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> 
> 
> 
> _______________________________________________
> Bacula-users mailing list
> Bacula-users AT lists.sourceforge DOT net
> https://lists.sourceforge.net/lists/listinfo/bacula-users
> 

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users