Generating Basic Bacula Backup Email Summary Reports (Updated Version)

In April of 2013, a request was made on the Bacula mailing list for a way to get daily and weekly backup reports. This got me to thinking that such a daily email would be useful.

So, off I went to write a simple bash shell script to generate these reports. Over time, many features were added to this script and it has evolved quite a bit over the past 4 years. The original posting about this script may be found here: http://www.revpol.com/baculasummaryemails-ORIG

The script expects to see one command line parameter which is the number of hours to report on. The following would generate a report going back 24 hours:

$ baculabackupreport.sh 24

The plain text version of this email report would something look like this:



The HTML version of this email report would look something like this:

AttachmentSize
baculabackupreport-20171202.sh38.77 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for the patch!

Spaces in file names, spaces in job names... Something I always avoid by using camelCase, or like you by using underscores instead of spaces, so I never even thought of that.

The next release will include this fix.

Thanks for contributing.

Best regards,

Bill

Patch for job Names with spaces

--- baculabackupreport-20170515.sh	2017-05-15 19:15:00.000000000 +0200
+++ baculabackupreport-20170701.sh	2017-07-01 16:16:35.811119457 +0200
@@ -128,7 +129,7 @@
 # -------------------------------------------------------------------
 case ${dbtype} in
 	mysql )
-		queryresult=$(echo "SELECT JobId, Name, StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
+		queryresult=$(echo "SELECT JobId,  REPLACE(Name,' ','_'), StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
 		TIMEDIFF (EndTime,StartTime) as RunTime, JobErrors \
 		FROM Job \
 		WHERE (RealEndTime >= DATE_ADD(NOW(), INTERVAL -${hist} HOUR) OR JobStatus='R') \
@@ -138,7 +139,7 @@
 		;;

 	pgsql )
-		queryresult=$(echo "SELECT JobId, Name, StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
+		queryresult=$(echo "SELECT JobId, REPLACE(Name,' ','_'), StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
 		AGE(EndTime, StartTime) as RunTime, JobErrors \
 		FROM Job \
 		WHERE (RealEndTime >= CURRENT_TIMESTAMP(2) - cast('${hist} HOUR' as INTERVAL) OR JobStatus='R') \
@@ -148,7 +149,7 @@
 		;;

 	mariadb )
-		queryresult=$(echo "SELECT JobId, Name, StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
+		queryresult=$(echo "SELECT JobId, REPLACE(Name,' ','_'), StartTime, EndTime, Type, Level, JobStatus, JobFiles, JobBytes, \
 		TIMEDIFF (EndTime,StartTime) as RunTime, JobErrors \
 		FROM Job \
 		WHERE (RealEndTime >= DATE_ADD(NOW(), INTERVAL -${hist} HOUR) OR JobStatus='R') \
@@ -174,6 +175,7 @@
 		results="1"


+echo ${queryresult}
 # Now for some fun with awk
 # -------------------------
 IFS=" "

Regards,
Sandro W.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <b> <i> <u> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Y
Q
7
&
e
i
Enter the code without spaces and pay attention to upper/lower case.