Sunday, 14 November 2010

Configuring Bacula Tray Monitor on Ubuntu

I use Bacula to back up my servers and desktop/laptop computers. It's always bugged me that I didn't have a little icon on my Ubuntu desktop showing the status of the backup: whether it was running or not and some indication of progress. Most backup systems have this. In Bacula it's called the tray monitor. The configuration file documentation seemed straightforward, but it took a lot of fiddling to get it right.

I think I have a fairly typical situation:
  • A backup server with a direct attached backup storage device (in my case, two: a USB-connected 1 TB hard drive, and a DAT-72 tape drive)
  • Several clients being backed up on a regular schedule
  • One client is the laptop I use as my normal workstation. This is the one I want to put the tray monitor on
  • I'm already successfully backing up this configuration, so all my passwords in my Bacula configuration files are correct, and all my firewalls are configured to allow the backup to work
  • The laptop and the backup server are both running Ubuntu 10.04
Here's what I did to get the tray monitor to work (read my notes below before you start cutting and pasting the following into your configuration):
  1. I installed the tray monitor software on my laptop:
  2. sudo apt-get install bacula-traymonitor
    
  3. On my laptop I changed the tray monitor configuration file (/etc/bacula/tray-monitor.conf) to look like this:
  4. Monitor {
      Name = backup02-mon
      Password = "Monitor-Password"
      RefreshInterval = 5 seconds
    }
    
    Client {
      Name = pacal-mon
      Address = pacal.pender.jadesystems.ca
      FDPort = 9102
      Password = "Monitor-Password"
    }
  5. Still on the laptop, I added the following to the file daemon, aka backup client, configuration file (/etc/bacula/bacula-fd.conf):
  6. # Restricted Director, used by tray-monitor to get the
    #   status of the file daemon
    
    Director {
      Name = backup02-mon
      Password = "Monitor-Password"
      Monitor = yes
    }
  7. I restarted the file daemon on the laptop (don't forget this or you'll confuse yourself horribly):
  8. sudo service bacula-fd restart
    
  9. On the backup server, I added the following to the director configuration file (/etc/bacula/bacula-dir.conf):
  10. # Restricted console used by tray-monitor to get the status of the director
    Console {
      Name = backup02-mon
      Password = "Monitor-Password"
      CommandACL = status, .status
    }
  11. Finally, I reloaded the configuration file on the backup server:
  12. sudo bconsole 
    reload 
    exit 
    
  13. Now all I had to do is start the tray monitor. The command line is:
  14. bacula-tray-monitor -c /etc/bacula/tray-monitor.conf
Then I made a menu item for it. I put it in Applications-> System Tools.
  1. Select System-> Preferences-> Main Menu
  2. Select "System Tools" on the left side of the window
  3. Click on the "New Item" button on the right side of the window
  4. Fill in the "Name:" box with "Bacula Tray Monitor" and the "Command:" box with the command line above
  5. Click "OK"
  6. Click "Close" in the "Main Menu" window
Notes:
  • I used a separate password specifically for the monitor. The tray monitor's configuration file has to be readable by an ordinary user without special privileges. So anyone can see the password. Don't use the same password for the monitor as you use for the director or the file daemons, or you'll be making it easy for anyone who gets access to your computer to read all the files on your network.
  • You have to change to above bits of configuration file to match your particular configuration. Change: "laptop.example.com" to the fully qualified domain name of the computer on which you're installing the tray monitor. Change "Monitor-Password" to something else more secure that everyone who reads this blog doesn't know about. 
  • "backup02-mon" and "laptop-mon" are both names you can change to be anything you want them to be. In my case, "backup02-mon" means the monitor on the backup server (hostname: backup02), and "laptop-mon" means the monitor on the laptop (hostname: laptop)