Hi all

I just thought I'd share this with you as you may find it useful. My
managers wanted to receive a summary email of the previous nights
backups which contained only basic information of the status of the
backups, and they wanted this all in one email. As far as I can tell,
there is no way to get just a summary report from bacula its self
(forgive me if I am wrong), so I wrote a little script to produce the
summary.

For this script to work, I have all of the bacula report mails cc'd to a
local account on the bacula server (strangely enough, the account is
called 'bacula'). This script then runs at the end of the last backup,
summarises all of the report mails in to one email, then empties the
mailbox.

I have only used this script with bacula-1.38.0 - previous versions
*may* have slightly different report mails on which my script will not
work, but I'm sure just a little tweaking of my script will fix that.

Here it is:

-------------------------------------
#!/bin/sh
# This script is to create a summary of the job notifications from
bacula
# and send it to people who care.
# Tested with bacula-1.38.0

# Use awk to create the report, pass to column to be 
# formatted nicely, then on to mail to be sent to
# port who care.
awk -F\:\  'BEGIN {
                print "Client Status Type StartTime EndTime Files Bytes"
        }
        /Client/ {
                CLIENT=$2; sub(/"/, "", CLIENT) ; sub(/".*$/, "",
CLIENT)
        }
        /Backup Level/ {
                TYPE=$2 ; sub(/,.*$/, "", TYPE)} /Start time/
{STARTTIME=$2; sub(/.*-.*-.* /, "", STARTTIME)
        }
        /End time/ {
                ENDTIME=$2; sub(/.*-.*-.* /, "", ENDTIME)
        }
        /SD Files Written/ {
                SDFILES=$2} /SD Bytes Written/ {SDBYTES=$2
        }
        /Termination/ {
                TERMINATION=$2 ;sub(/Backup/, "", TERMINATION) ;
                printf "%s %s %s %s %s %s %s \n",
CLIENT,TERMINATION,TYPE,STARTTIME,ENDTIME,SDFILES,SDBYTES
        }' /var/spool/mail/bacula   | \
     column -t |
     mail -s "Bacula Summary for `date -d yesterday +%a,\ %D`"
[EMAIL PROTECTED]
# Empty the mailbox
cat /dev/null > /var/spool/mail/bacula
# That's all folks.
-------------------------------------

The output of the report looks like:

Client       Status  Type          StartTime  EndTime   Files   Bytes
server1      OK      Differential  23:56:02   00:11:02  12,458
1,951,197,803
server2      OK      Differential  23:19:46   00:13:20  233
28,612,022,635
server3      OK      Differential  00:11:04   00:21:31  5,134
732,374,476
server4      OK      Differential  00:21:34   00:21:44  491
34,332,329
server5      OK      Differential  00:21:47   00:25:56  75
636,753,005
server6      OK      Differential  00:13:22   00:26:10  9,232
4,011,694,684

Regards

Andrew


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to