Send Email Bacula Report Perl Script (Davide Giunchi)
  • Post category:Uncategorized
  • Post comments:0 Comments

The standard “Messages” Bacula function send a separate email for every backup job, when you manage a large backup servers this will make you receive hundred of email every day, and a “daily digest” will be better.

Captura de tela de 2016-04-01 17-20-28

This is a Perl program that works with Bacula, it send a digest email of the backup jobs run in the last X days, you can run it every morning to notify about the state of every job run in the night, or every monday to get the state of the week-end backups.

You need to install the program in the Bacula (Enterprise or community) Director server that use MySQL or PostgreSQL database.

All the parameters are configurable on the config file /etc/bacula/send_bacula_backup_report.conf , the email report use the “HTML::Template” template engine, so you can customize the email layout as you wish.
The default email layout is the same of the Bweb html interface, so if you are confident with bweb, you will immediately understand the output.
You will fast and easly understand every job result by take a look at the “Status” field, you will get one the following states:

OK: all right
ERROR: fatal error
WARNING: job ok but maybe some files are in use (without VSS), some directory are missing ecc…
RUNNING: job is still running when Send Bacula Backup Report has been run
WAITING: job queued and waiting for start
ATTENTION (new feature in 0.6): job ok but the backup size is smaller thank the expected one

In every case where the status is not OK, click on the job status to connect to the web interface (if installed) and view more details.
Even if all jobs are OK, please remember to do some restore tests on a regular basis to check that you save all the needed directory/files and the data are correct restored.


 

Steps for running Send Bacula Backup Report (tested on Bacula 7.4):

1) You need a working Bacula or Bacula Enterprise with MySQL or PostgreSQL database and a working local MTA (in this example, postfix)

2) Install the required Perl modules,

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:

Enable the repoforge repository: http://repoforge.org/use/http://repoforge.org/use/

yum install perl-HTML-Template perl-MIME-Lite perl-DBD-MySQL perl-DBD-Pg postfix

3) install the program and configuration files

cd /tmp

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.pl /etc/bacula/scripts/

cp send_bacula_backup_report.conf.example /etc/bacula/send_bacula_backup_report.conf

cp send_bacula_backup_report.tpl /etc/bacula/

chmod 750 /etc/bacula/scripts/send_bacula_backup_report.pl

chmod 640 /etc/bacula/send_bacula_backup_report.conf

4) Modify the configuration file:

vi /etc/bacula/send_bacula_backup_report.conf

You will surely need to modify the content of that variables: db_type, db_password, bweb_path, email_from, email_to
You can define as many “$minimum_size” rules as you want, but this is optional.

5) Only if you use PostgreSQL Catalog:

su posgres "psql bacula < /path/to/send_bacula_backup_report-src/functions-postgresql.sql"

6) Try if it works correct:

/etc/bacula/scripts/send_bacula_backup_report.pl 1

then check you email. If you have any problems check your /var/log/mail.log and maybe refer to: http://bacula.us/authenticated-mail-sending/

7) Enable daily email report via crontab, add the following lines to /etc/crontab:

---
# send daily bacula backup report
15 8 * * 2-5 root /etc/bacula/scripts/send_bacula_backup_report.pl 1 >/dev/null
15 8 * * 1 root /etc/bacula/scripts/send_bacula_backup_report.pl 3 >/dev/null
---

This example will send a daily digest from Tuesday to Friday on the backup of the previous night. On Monday it will send a
digest on the backup of the entire week-end.


 

Source: https://giunchi.net/send-bacula-backup-report

Disponível em: pt-brPortuguês (Portuguese (Brazil))enEnglish

Leave a Reply