Gentoo Wiki




Bacula is a set of computer programs that permit you (or the system administrator) to manage backup, recovery, and verification of computer data across a network of computers of different kinds. It has a very large documentation on the Internet. A good one is the "Baculapedia" Project - colaborative documentation for Bacula.

In technical terms, it is a network based backup program.

Bacula is relatively easy to use and efficient, while offering many advanced storage management features that make it easy to find and recover lost or damaged files.


In this tutorial we will set up Bacula 2.x and configure it with one client while explaining all relevant configuration options along the way.

Please note that we are only using a subset of all options and possibilites of Bacula. Bacula is useable as a small backup solution but is mainly designed as a corporate backup system, with a robust and very extensive framework. For more information as well as detailed information about some of the options used below you should have a look at the Bacula user manual.

Warning: Bacula is a network backup solution designed for corporate size backups: multiple terabytes coming from hundreds of machines. It is a data backup NOT a bare metal backup system.

In a nutshell this means it is not designed for restoring a whole system from backup on a new drive (bootable anyway). You might be able to pull it off to restore Linux using a box of tricks and hacks (I've tested this) but the average user can't do this and when you are planning on backing up a Windows machine you might as well stop reading right now if you wanted to do bare metal backups on that platform (think registry hell).

As long as you just want your data backed up you're reading the right manual - Bacula excels in backing up data over a network.

Getting Started

As of this writing (May 3rd, 2007) the most recent Bacula version is 2.0.3 and can be found in Gentoo Portage. So start out by updating your portage to the latest info and install it:

emerge --sync
emerge -av bacula

Note that Bacula requires some database backend for the master server, the one running the so called Director. There are other backends besides MySQL like SQLite but some of them have some restrictions. If you don't use a database or don't mind installing MySQL I suggest you add it to your use flags in /etc/make.conf and just roll with MySQL. If you were installing on a client (see below) you wouldn't need the database backend.

It could be that the 1.x branch of Bacula is marked stable for you. To get the new 2.x branch (which is already running in production servers so it should be safe to use) add Bacula to the keywords file:

echo "app-backup/bacula ~x86" >> /etc/portage/package.keywords

Replace the arch flag with the one for your system. Bacula 2.0.3 is running fine on x64 as well.

Next we have to create a database and a user for Bacula on the database backend. The -p flag makes the script ask for a password (which every administrator should have set on his database):

mainserver ~ # cd /usr/libexec/bacula/
mainserver bacula # ./create_bacula_database -p
mainserver bacula # ./make_bacula_tables -p
mainserver bacula # ./grant_bacula_privileges -p

PostgreSQL rather than MySQL?

If you're using PostgreSQL, don't use the "-p" option in the above commands, but rather "-W -U username", where username is the database user that you have set up for Bacula to use.

Note: You have to use psql commands to create a new database "user" or "role" before you can issue the commands below, unless you want to go with the default "postgres" user/role.

Versions of PostgreSQL earlier that 8.2 may have a slightly different syntax. Check your database documentation for details.

To use the default user, "postgres", use the following:

mainserver ~ # cd /usr/libexec/bacula/
mainserver bacula # ./create_bacula_database -W -U username
mainserver bacula # ./make_bacula_tables -W -U username
mainserver bacula # ./grant_bacula_privileges -W -U username

You may also want to edit the file /usr/libexec/bacula/create_postgresql_database (which is the script mentioned above) and change the default encoding of the database to UTF8 rather than SQL_ASCII. Simply remove the # before the line you want use and add a #before the other line. NOTE: Before you choose to use encodings other than SQL_ASCII, please read

How does Bacula work

Lets begin explaining how Bacula is build up. Bacula consists of roughly 4 programs working together on the network to function as one backup system.

The master controlling all operations is the Director. As its name implies, it's the one running the show. It tells other parts of the backup system what to do, when to do it and basically is the central brain of the backup system. Every other program dials in on the Director to receive commands.

The Director is pretty autonomous once set up, but when you want to control it to run jobs by hand or restore some files you will need the Console. The Console is the main application for talking to the director to get feedback on what it's doing. Don't get fooled by the so-called graphical tools - as of this writing there is a graphical suite in development to do the tasks the Console does in a nice GUI but its not stable nor complete. All the other tools, like wxConsole and the like, are pretty much just a graphical shell on top of the Console and require interaction like a normal console, so they don't really add much functionality. On a side note, there is a tray monitor to talk to the Bacula services, but that's a fairly read-only tool, so its like the little side-kick of the Console.

The third program interacting with the Director is the File Daemon (FD). The FD is the program which gets deployed on each and every computer you need to get information from. It runs with privileges to read all relevant files and can run commands before or after backup jobs.

The fourth is the Storage Daemon (SD). This is the program with the important task of storing data. It runs on one or multiple computers (depending on how much data you need to store and on what media). The SD can store data in files on a hard disk, burn them on CD/DVD, control a mass CD/DVD burning system, use a tape system, automatic tape changer - whatever you want. As long as the storage device is supported on linux, it will probably work with Bacula. (For more information on supported tape systems, see the Bacula manual: )

Situation Description

We assume we have a server somewhere which has an installed Bacula system. We will use the Director and Storage Daemon on this server (so we will store the data on the same machine that runs the Director). Because Bacula uses the File Daemon to backup its own data files we will activate the File Daemon but we won't use it for our own purposes on the main server.

We will install Bacula on a secondary server using the following use flags. This will install only the File Daemon and not the rest of Bacula:

echo "app-backup/bacula bacula-clientonly -bacula-console bacula-nodir bacula-nosd " >> /etc/portage/package.use
emerge -av bacula

The secondary server will be backed up on the main server using file storage - no tape streamers, to keep it simple.

Configuration files

We will now discuss each configuration file per program. We will start by describing the File Daemons first, then the Storage Daemon followed by the Console and finally the Director itself. The Director configuration can be quite puzzling at first but we'll explain everything in detail.

File Daemon Configuration

File: /etc/bacula/bacula-fd.conf
 # List Directors who are permitted to contact this File daemon
 Director {
   Name = myserver-dir
   Password = "my-very-long-automatically-generated-password-for-accessing-this-fd"

 # "Global" File daemon configuration specifications
 FileDaemon {                           # this is me
   Name = myclient-fd                   # my name - is used by the director as well
   FDport = 9102                  	# where we listen for the director
   WorkingDirectory = /var/bacula
   Pid Directory = /var/run
   Maximum Concurrent Jobs = 20

 # Send all messages except skipped files back to Director
 Messages {
   Name = Standard
   director = myserver-dir = all, !skipped, !restored

Note that the password under the Director section should match the password specified for section describing this file daemon in the Director configuration on the main server. Besides the password the name of the director should match too, if the name is wrong the FD will reject the director and abort connecting.

Most people can probably live with this default setup so leave everything as it is.

Note that we have to set up this configuration twice: once on the secondary server that needs to be backed up and once on the main server because Bacula wants to back itself up. If you don't need fancy configurations at this stage you can probably set them up as per our example. Just give both the proper names and passwords and you're set.

Tip: Use the hostname of the computer running the service to be able to remember the names: for example you will have myserver-fd, myserver-sd, myserver-dir and myclient-fd in this Howto.

Storage Daemon Configuration

The Storage Daemon is a complex piece of software to set up. For all the options please look at the Bacula Manual: .

File: /etc/bacula/bacula-sd.conf
 # Storage daemon setup voor myserver

 Storage {                               # definition of myself
   Name = myserver-sd
   SDPort = 9103                         # Director's port
   WorkingDirectory = "/var/bacula"
   Pid Directory = "/var/run"
   Maximum Concurrent Jobs = 20

 # List Directors who are permitted to contact Storage daemon
 Director {
   Name = myserver-dir
   Password = "another-automatically-generated-password-which-should-match-the-one-in-bacula-dir.conf"

 # Devices supported by this Storage daemon
 # To connect, the Director's bacula-dir.conf must have the
 #  same Name and MediaType.

 Device {
   Name = FileStorage		# name for the storage media
   Media Type = File		# type of media storage
   Archive Device = /backups	# where to store the files
   LabelMedia = yes;            # lets Bacula label unlabeled media
   Random Access = Yes;		# this is a hard disk so it has random access
   AutomaticMount = yes;        # when device opened, read it
   RemovableMedia = no;		# fixed media, not replacable
   AlwaysOpen = no;		# even though its a hard drive, don't keep the files open

 # Send all messages to the Director,
 # mount messages also are sent to the email address
 Messages {
   Name = Standard
   director = myserver-dir = all

Once again, this file is straight-forward and you should look at the Bacula Manual for more information on, for example, using a tape drive. Note that if you wanted to park the SD on a different machine this wouldn't be a problem at all. For easy naming, change the name of the Storage section to the one of the new machine and tell the Director the proper place to find the SD.

Console Configuration

This configuration file allows a console to connect to the Director and interact with it. The console is running on the primary server in this example so thats where this file should go. It is ofcourse possible to install the console somewhere else and connect remotely to the Director. Just don't forget to give the new Console access in the Director configuration.

File: /etc/bconsole.conf
 # Bacula User Agent (or Console) Configuration File

 Director {
   Name = myserver-dir			# name of the Director we are connecting to - must match the actual  name used
   DIRport = 9101
   address = myserver			# remote address of the Director - use a hostname here
   Password = "mysecretpassword"	# password for logging in on the Director

Wrapping it up

Bacula is too complicated to describe all its functionality in one howto. If you are looking for a simple backup script or a bare metal backup, you won't need Bacula. If you need a data backup on one or more computers over a network, Bacula is the tool for the job. If at first the shear amount of options give you the shivers, read the manual once more and hit the forums. Only commercial packages come with a feature set like Bacula and maybe with a decent GUI. The lack of a graphical interface might deter few but with time the BAT utility might mature to a useable state solving the lack of point and click interaction.

See also

Retrieved from ""

Last modified: Thu, 18 Sep 2008 06:14:00 +0000 Hits: 10,263