East of the Sun, West of the Moon


Bacula scripting

Filed under: Projects,Software — Erwin @ 10:08 pm

I’ve been using Bacula for a year or two now, I think, and the one thing that had been irritating me for most of that time is that every morning I’d be presented with X emails, one for each machine that’s been processed and another for the backup of the catalog itself, and have no idea at the end of it how much had changed (and backed up) on which machines, and where any anomalies might have occured.

So I began work on /etc/bacula/scripts/summary.pl, with the intention of emailing me its output and, no longer needing them, automatically filing away those individual Bacula reports marked as read in a folder where I could dig them up for closer inspection if necessary.

I use the SQLite back-end, but it is trivial to adjust it to a MySQL back-end, for anyone who’s worked with DBI before.

You can glance at source code and use it as you see fit (if it breaks, you get to keep both pieces, you get the idea).

The basic plan is to either run it as Run Before script in a separate administrative job with a sufficiently low priority that it runs after the catalog backup, or to run it as a Run After script in the catalog backup job itself. Either way it may not run as root so make sure you put the summary.stamp in a location where the Bacula running user can read and write.

The output will look like this:

Summary of jobs finished since Mon Sep 18 03:53:04 2006:
Job  Name            End Time        Size     Files   Err Miss Status Level
3490 JobName1        09-19 03:15:13    147 MB    2224   0    0 T      I (B)
3491 JobName2        09-19 03:16:58     37 MB    3502   0    0 T      I (B)
3495 JobNameN        09-19 03:22:43   1091 kB      84   0    0 T      I (B)
3496 BackupCatalog   09-19 03:48:10    187 MB       1   0    0 T      F (B)

Ideas for improvement are to separate the failed jobs (the ones with status f) from the rest, or to squeeze even more information into it, but for the moment I’m sufficiently happy with this leap forward that I’m giving it a rest. There are always other projects that could use my attention, after all.

Powered by WordPress