The “Message” – Bacula function that sends a separate email for each backup job, can quickly fill the box of users who will not necessarily analyze the backup logs. For these, a “daily summary” may be better, as follows.
This is a Perl program that works with Bacula, it is to send a digest email of the backup jobs performed in the last X days, you can run it every morning to notify about the status of each job execution during the night, or every Monday to get the status of weekend backups.
You need to install the program on the Bacula (Enterprise or community) Director server using MySQL or PostgreSQL databases.
All parameters are configurable in the /etc/bacula/send_bacula_backup_report.conf configuration file, the email report uses the “HTML :: Template” template engine, so you can customize the email layout as you wish .
The default email layout is the same as the Bweb html interface, so if you are confident with BWEB, you will immediately understand the output.
You will quickly and easily understand each job result, take a look at the “Status” field, you will have one of the following states:
- OK: Alright
- ERROR: fatal error
- WARNING: ok, but maybe some files are in use (without VSS), some directories are missing ecc …
- RUNNING: job is still running when Submit Bacula backup report was run
- WAITING: queued and waiting to start
- ATTENTION (new feature in 0.6): work ok, but the backup size is smaller than expected
In all cases where the status is not OK, click on the job status to connect to the bacula-web interface (if installed) and view more details.
Even though all jobs are OK, please remember to do some restore tests on a regular basis to make sure you save all the necessary directory / files and the data is correctly restored.
Script Installation Steps (tested on Bacula 9.x and higher):
1) You need a Bacula working or Bacula company with MySQL or PostgreSQL and a local working MTA (in this example, postfix)
2) Install the required perl packages (dependencies).
On Debian/Ubuntu:
apt-get update apt-get install libhtml-template-perl libmime-lite-perl libdbd-mysql-perl libdbd-pg-perl postfix
On RedHat/CentOS:
yum -y install wget epel-release yum install perl-HTML-Template perl-MIME-Lite perl-DBD-MySQL perl-DBD-Pg postfix
3) Install the program
cd /opt/bacula/scripts wget https://giunchi.net/wp-content/uploads/2015/01/send_bacula_backup_report-0.6.tar.gz tar -xzvf send_bacula_backup_report-0.6.tar.gz cp send_bacula_backup_report.conf.example send_bacula_backup_report.conf sed -i 's|/etc/bacula|/opt/bacula/scripts|g' ./send_bacula_backup_report.conf sed -i 's|/etc/bacula|/opt/bacula/scripts|g' ./send_bacula_backup_report.pl chmod 750 /opt/bacula/scripts/send_bacula_backup_report.pl chmod 640 /opt/bacula/scripts/send_bacula_backup_report.conf chown bacula /opt/bacula/scripts/send*
4) Modify the configuration file:
vi /opt/bacula/scripts/send_bacula_backup_report.conf
Check and configure the following variables: db_type, db_password, bweb_path, email_from, email_to
You can also define the number of entries in the $minimum_size rules as you want report, but it is optional.
5) PostgreSQL Catalog only:
su postgres "psql bacula < /opt/bacula/scripts/send_bacula_backup_report-src/functions-postgresql.sql"
6) Test the email sending:
sudo -u bacula /opt/bacula/scripts/send_bacula_backup_report.pl 1
Check your email. If you have problems see refer to /var/log/mail.log.
7) Create a JobAdmin to run the script or enable daily sending via crontab. Add the following lines to /etc/crontab:
--- # send daily bacula backup report 15 8 * * 2-5 bacula /opt/bacula/scripts/send_bacula_backup_report.pl 1 >/dev/null 15 8 * * 1 bacula /opt/bacula/scripts/send_bacula_backup_report.pl 3 >/dev/null ---
In this example, the report will be sent daily from Tuesday to Friday, the night before. The second email will be sent for the last 3 days.
8) Important! In case of sudo permission execution errors, grant:
visudo # Acrescente a seguinte linha: bacula ALL=(ALL) /opt/bacula/scripts/send_bacula_backup_report.pl
Save and quit.
BWeb – Bacula Enterprise Integration:
Change the URL for your production BWeb in send_bacula_backup_report.conf:
vi /opt/bacula/scripts/send_bacula_backup_report.conf # Change the following similar line to: $bweb_path='http://192.168.0.x:9180/';
Change the BWeb job display string in send_bacula_backup_report.tpl. Example:
vi /opt/bacula/scripts/send_bacula_backup_report.tpl # Change the following similar line to: <td style="padding-left: 3px; padding-right: 3px;" classname="dataTD10"><a href="<TMPL_VAR NAME=Bweb_Path>/cgi-bin/bweb /bweb.pl?action=job_zoom&jobid=<TMPL_VAR NAME=JobId>"><TMPL_VAR NAME=Status></a></td>
After the changes, the new emails will contain links to the Job detail on Bweb.
Source: https://giunchi.net/send-bacula-backup-report
Disponível em: Português (Portuguese (Brazil))EnglishEspañol (Spanish)