oreilly.comSafari Books Online.Conferences.


Bacula: Cross-Platform Client-Server Backups
Pages: 1, 2, 3

Labeling a Volume

A Volume is either a tape or a disk. Bacula puts a label on each Volume for identification by writing a special header at the start of the Volume. In the case of tapes, you should also physically label the tape with the same name. This will allow you to identify Volumes when you need them. When the time comes to restore a particular file, Bacula will tell you what Volumes are needed.

Use the label command to label a Volume. In the following example, I'm just going to label a file store, not a tape store.

Using default Catalog name=MyCatalog DB=bacula
Automatically selected Storage: File
Enter new Volume name: estVolume1
Automatically selected Pool: Default
Connecting to Storage daemon File at
Sending label command for Volume "TestVolume1" Slot 0 ...
3000 OK label. Volume=TestVolume1 Device=/tmp
Catalog record for Volume "TestVolume1", Slot 0 successfully created.
Requesting mount FileStorage ...
3906 cannot mount non-tape.
Do not forget to mount the drive!!!

Complete documentation is available at Labeling Your Volumes.

Running a Backup Job

Bacula comes with a preset backup job that will get you started. It will backup the directory from which Bacula was installed. Once you get going and have created your own jobs, you can safely remove this job from the Director configuration file.

Bacula runs jobs automatically at the time set within the Schedule resource for the Job in question. For more information, please refer to the Job Resource documentation.

Here's how to run a job manually:

A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
Select Job resource (1-3): 1
Run Backup job
JobName:  Client1
FileSet:  Full Set
Level:    Incremental
Client:   laptop-fd
Storage:  File
Pool:     Default
When:     2003-11-02 16:30:33
Priority: 10
OK to run? (yes/mod/no): yes
Run command submitted.

If I had selected mod, I would have been able to modify any of the job parameters, such as level of backup (incremental, differential, full), use another storage device, or change the run time.

Here's the output of the job as it runs:

02-Nov-2003 16:52 laptop-dir: Start Backup JobId 2,
02-Nov-2003 16:52 laptop-sd: Volume "TestVolume1" previously
written, moving to end of data.
02-Nov-2003 16:52 laptop-dir: Bacula 1.32c (30Oct03): 02-Nov-2003
JobId:                  2
Job:                    Client1.2003-11-02_16.52.00
Backup Level:           Incremental, since=2003-11-02 16:30:40
Client:                 laptop-fd
FileSet:                "Full Set" 2003-11-02 16:30:40
Start time:             02-Nov-2003 16:52
End time:               02-Nov-2003 16:52
FD Files Written:       1,116
SD Files Written:       1,116
FD Bytes Written:       14,729,577
SD Bytes Written:       14,895,089
Rate:                   359.3 KB/s
Software Compression:   None
Volume name(s):         TestVolume1
Volume Session Id:      2
Volume Session Time:    1067808016
Last Volume Bytes:      14,946,342
Non-fatal FD errors:    0
SD Errors:              0
FD termination status:  OK
SD termination status:  OK
Termination:            Backup OK

02-Nov-2003 16:52 laptop-dir: Begin pruning Jobs.
02-Nov-2003 16:52 laptop-dir: No Jobs found to prune.
02-Nov-2003 16:52 laptop-dir: Begin pruning Files.
02-Nov-2003 16:52 laptop-dir: No Files found to prune.
02-Nov-2003 16:52 laptop-dir: End auto prune.


This information will also be sent to you via email, depending on the settings within your Director configuration file. (Look for the Messages resource). You will notice that this backup was JobId 2. What happened to Job 1? When I first ran this job, it failed because the directory specified in the FileSet did not exist. I created and populated the directory, and then re-ran the job, which produced the output shown above.

Restoring Files

Here's a simple restore job. Bacula includes one by default. You can use it for just about anything.

In the following example, I will restore the entire file set, demonstrating how to be selective about what files are restored. I will do a few directory listings so you can see how that works.

Using default Catalog name=MyCatalog DB=bacula

First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.

To select the JobIds, you have the following choices:
     1: List last 20 Jobs run.
     2: List Jobs where a given File is saved.
     3: Enter list of JobIds to select.
     4: Enter SQL list command.
     5: Select the most recent backup for a client.
     6: Select backup for a client before a specified time.
     7: Enter a list of files to restore.
     8: Enter a list of files to restore before a specified time.
     9: Cancel.
Select item:  (1-9): 3
Enter JobId(s), comma separated, to restore: 2
You have selected the following JobId: 2
Building directory tree for JobId 2 ...
1 Job inserted into the tree and marked for extraction.
Automatically selected Storage: File

You are now entering file selection mode where you add and
remove files to be restored. All files are initially added.
Enter "done" to leave this mode.

cwd is: /
$ ls
$ cd usr
cwd is: /usr/
$ ls
$ cd ports/sysutils
cwd is: /usr/ports/sysutils/
$ ls
$ cd bacula/work/
cwd is: /usr/ports/sysutils/bacula/work/
$ ls
$ cd bacula-1.32c
cwd is: /usr/ports/sysutils/bacula/work/bacula-1.32c/
$ ls
$ done
Bootstrap records written to /var/db/bacula/restore.bsr

The restore job will require the following Volumes:


1116 files selected to restore.

Automatically selected Client: laptop-fd
Run Restore job
JobName:    RestoreFiles
Bootstrap:  /var/db/bacula/restore.bsr
Where:      /tmp/bacula-restores

Replace:    always
FileSet:    Full Set
Client:     laptop-fd
Storage:    File
When:       2003-11-02 16:59:53
Priority:   10
OK to run? (yes/mod/no): yes
Run command submitted.
Restore command done.

Again, as with the running of a job, if I had selected mod instead of yes, I would have been able to modify any of the job parameters, including the path to which the files should be restored. You should choose the restore location carefully, to ensure there is sufficient disk space available.

The output from this job is rather long, listing every file restored, so I won't include it here. That is the default action, but you can change it in the configuration file.

The restored files are at /tmp/bacula-restores. It is easy to verify that the restored files match the original:

# diff -ruN /tmp/bacula-restores/usr/ports/sysutils/bacula/work/bacula-1.32c \

No differences. That's rather convenient, considering I just did a backup and restore. I would be concerned if there was a difference.

This was just a simple example. Bacula has a chapter devoted to the restore command.

Creating Backup Schedules

Bacula comes preset with a simple backup schedule. You can use that or create new Schedules to meet demand. The Director configuration documentation is useful for that task. For my testing, I wanted to backup files on my Windows XP machine every hour. I created this schedule:

Schedule {
  Name = "HourlyCycle"
  Run  = Full 1st sun at 1:05
  Run  = Differential 2nd-5th sun at 1:05
  Run  = Incremental Hourly

Any Job that uses this schedule will be run at the following times:

  • A full backup on the first Sunday of every month at 1:05 a.m.
  • A differential backup on the 2nd, 3rd, 4th, and 5th Sundays of the month at 1:05 a..
  • An incremental backup, every hour, on the hour.

You can go wild with this scheduling, creating whatever frequency you need. But as you can see, one schedule, for one job, can create many different instances of that combination. You can backup as frequently as you need with the level of backup that's right for you.

If you are wondering what the different types of backups mean, please read the Level documentation in the Director configuration documentation.

Creating a Client-only Install

So far we have tested Bacula on the server. In this section I will install the Bacula client on a client machine. I will also show you the changes you need to make to the Bacula server.

With the FreeBSD port, installing a client-only version of Bacula is done with this command:

# cd /usr/ports/sysutils/bacula/
# make -DWITH_CLIENT_ONLY install

If you are manually compiling from source, look at the --enable-client-only option documented in the Installing Bacula documentation.

A simple solution, if the platforms are the same, is to copy the bacula-fd binary and bacula-fd.conf configuration file from one box to another. Don't forget to copy the startup file too.

You will also need to tell the Director about this client by adding a new Client resource to the Director configuration file. You will also want to create a Job and FileSet resource.

The Bacula documentation has a section on Adding a Second Client.

Remember to restart the daemons when you make changes to the Bacula configuration files. For a FreeBSD system, this is easiest done with this command:

# /usr/local/etc/rc.d/ restart
Stopping the Storage daemon
Stopping the File daemon
Stopping the Director daemon
Starting the Storage daemon
Starting the File daemon
Starting the Director daemon

If that script does not exist on your computer, you will need to copy it from another.

Security Considerations

The security considerations for Bacula are pretty simple. Essentially, you want to ensure that the Bacula database files are not world-writable. The configuration files should not be world-readable. The Bacula ports should be protected from untrusted networks. You can also run the daemons as non-root, as outlined previously in this article, by using the -u and -g command line options.

Suggested Reading

I have not talked about Catalogs or Pools. A Catalog Resource defines what catalog should be used for a given job. You could have a catalog for each Client.

A Pool Resource defines the set of Volumes that can be used for a backup. This gives you the ability to store all incremental backups on one set of Volumes and all full backups on another set. You can do this by defining the Pools accordingly.

Bacula: A Solution with Wide Applications

I was first told about Bacula by an acquaintance on IRC. I don't recall the original discussion, but I immediately became interested in the application. Since that brief conversation six months ago, I've come to appreciate the simplicity of Bacula and the complex solutions that can be created with just a few components. The ability to use multiple Directors and multiple Storage Devices makes for a powerful combination.

Over that time, I've come to see how the Bacula community supports new people and how problems are quickly resolved. I feel this is imporant with any project. The Bacula mailing lists are low volume, with good responses to questions.

I've found Bacula to be ideal for backing up my small network of about a dozen computers. Whether you have one computer or hundreds, Bacula can give you the backups you need with the flexibility you want.

Dan Langille runs a consulting group in Ottawa, Canada, and lives in a house ruled by felines.

Return to the

Sponsored by: