]> git.sur5r.net Git - bacula/bacula/blob - bacula/examples/bacula_mail_summary.sh
Apply SunOS patch for ACLs submitted by David Duchscher.
[bacula/bacula] / bacula / examples / bacula_mail_summary.sh
1 #!/bin/sh
2 # This script is to create a summary of the job notifications from bacula
3 # and send it to people who care.
4 #
5 # For it to work, you need to have all Bacula job report
6 # mails cc'd to a unix mailbox called 'bacula', but of course you can edit
7 # as appropriate. This should be run after all backup jobs have finished.
8 # Tested with bacula-1.38.0
9
10 # Contributed by Andrew J. Millar <andrew@alphajuliet.org.uk>
11
12 # Use awk to create the report, pass to column to be
13 # formatted nicely, then on to mail to be sent to
14 # people who care.
15 EMAIL_LIST="peoplewhocare@company.com"
16 awk -F\:\  'BEGIN {
17                         print "Client Status Type StartTime EndTime Files Bytes"
18                 }
19         /Client/ {
20                 CLIENT=$2; sub(/"/, "", CLIENT) ; sub(/".*$/, "", CLIENT)
21         }
22         /Backup Level/ {
23                 TYPE=$2 ; sub(/,.*$/, "", TYPE)
24         }
25         /Start time/ {
26                 STARTTIME=$2; sub(/.*-.*-.* /, "", STARTTIME)
27         }
28         /End time/ {
29                 ENDTIME=$2; sub(/.*-.*-.* /, "", ENDTIME)
30         }
31         /SD Files Written/ {
32                 SDFILES=$2
33         }
34          /SD Bytes Written/ {
35                 SDBYTES=$2
36         }
37         /Termination/ {
38                 TERMINATION=$2 ;
39                 sub(/Backup/, "", TERMINATION) ;
40                 printf "%s %s %s %s %s %s %s \n", CLIENT,TERMINATION,TYPE,STARTTIME,ENDTIME,SDFILES,SDBYTES}' /var/spool/mail/bacula | \
41         column -t | \
42         mail -s "Bacula Summary for `date -d yesterday +%a,\ %D`" ${EMAIL_LIST}
43 #
44 # Empty the mailbox
45 cat /dev/null > /var/spool/mail/bacula
46 #
47 # That's all folks