Generating email warnings of Bacula jobs that complete "OK" but have zero files or zero bytes

A recent feature request on the Bacula Community version mailing list was to have Bacula set a job's status to "W" (Backup OK -- with warnings) when a job completed with zero files or zero bytes.

The general consensus was that this probably should be handled outside of Bacula code, since it would require and additional directive and of course additional coding.

This request interested me and it prompted me to write this short script.

After editing some basic variables near the top of the script, the script requires only one command line parameter - the jobid - and currently also accepts "debug" to log everything to stdout, and "zero_incremental_ok" which does not trigger when Incremental or Differential jobs have zero files or zero bytes.

Example email subject when an email report is triggered:

Subject: Warning from Bacula Server - Backup job 'SpeedyVMs' (jobid 18511) was "OK", but wrote zero files and/or zero bytes

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:

Getting Bacula's Bootstrap (.bsr) Files To A Safe Place Via Email

Here is a very simple script to make sure that your Bacula bootstrap files are emailed to an offsite system. This script may be called manually, or from a cron job, or from a Bacula Catalog backup job's "After" Runscript.

Automatically enabling/disabling removable vchanger volumes in Bacula database based on current availability

20130418 - Script re-written to utilize bconsole's "sqlquery" command to increase efficiency

Thanks to Josh Fisher for vchanger, and for recently sharing a few scripts on the Bacula mailing list which allow you to easily enable or disable all volumes in a pool, or all volumes on a vchanger magazine.

Making sure that only currently available volumes are enabled in Bacula's database solves a few issues - especially when using multiple removable magazines with vchanger.

The following script may be run manually when you swap removable media, or as a RunScript in an "Admin" type Bacula job. It will automatically determine which vchanger magazine(s) are inserted and available and will use bconsole's sqlquery command to to set the "Enabled" field in the Bacula database for all available volumes accordingly.