]> git.sur5r.net Git - bacula/bacula/blob - bacula/examples/reports/bacula_mail_summary.sh
kes Fix optional files in Makefile.in of src/filed that caused
[bacula/bacula] / bacula / examples / reports / 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 # loggin to file, edit path for Your needs
7 # This should be run after all backup jobs have finished.
8 # Tested with bacula-1.38.0
9
10 # Some improvements by: Andrey Yakovlev <freedom@kiev.farlep.net>  (ISP Farlep)
11 # Contributed by Andrew J. Millar <andrew@alphajuliet.org.uk>
12 # Patched by Andrey A. Yakovlev <freedom@kiev.farlep.net>
13
14 # Use awk to create the report, pass to column to be
15 # formatted nicely, then on to mail to be sent to
16 # people who care.
17
18 EMAIL_LIST="freedom@kiev.farlep.net"
19
20 LOG='/var/db/bacula/log'
21
22
23 #---------------------------------------------------------------------
24
25 awk -F\:\  'BEGIN {
26                         print "Client Status Type StartTime EndTime Files Bytes"
27                 }
28                 
29         /orion-dir: New file:/ {
30                 print $3
31         }
32         
33         /orion-dir: File:/ {
34                 print $3
35         }
36                 
37         /Client/ {
38                 CLIENT=$2; sub(/"/, "", CLIENT) ; sub(/".*$/, "", CLIENT)
39         }
40         /Backup Level/ {
41                 TYPE=$2 ; sub(/,.*$/, "", TYPE)
42         }
43         /Start time/ {
44                 STARTTIME=$2; sub(/.*-.*-.* /, "", STARTTIME)
45         }
46         /End time/ {
47                 ENDTIME=$2; sub(/.*-.*-.* /, "", ENDTIME)
48         }
49         /Files Examined/ {
50                 SDFILES=$2
51                 SDBYTES=0
52         }
53         /SD Files Written/ {
54                 SDFILES=$2
55         }
56         /SD Bytes Written/ {
57                 SDBYTES=$2
58         }
59         /Termination/ {
60                 TERMINATION=$2 ;
61                 sub(/Backup/, "", TERMINATION) ;
62                 gsub(/\*\*\*/, "", TERMINATION) ;
63                 sub(/Verify OK/, "OK-Verify", TERMINATION) ;
64                 sub(/y[ ]/, "y-", TERMINATION) ;
65                 printf "%s %s %s %s %s %s %s \n", CLIENT,TERMINATION,TYPE,STARTTIME,ENDTIME,SDFILES,SDBYTES}' ${LOG} | \
66         column -t -x | \
67         mail -s "Bacula Summary for `date -v -1d  +'%a, %F'`" ${EMAIL_LIST}
68 #
69 # Empty the LOG
70 cat ${LOG} > ${LOG}.old
71 cat /dev/null > ${LOG}
72 #
73 # That's all folks