Tuesday, May 19, 2009

Perform Client-Server Cross-Platform Backups with Bacula (Part 1)

Bacula is a powerful, flexible, open source backup program. .
Having problems finding a backup solution that fits all your needs? One that can back up both Unix and Windows systems? That is flexible enough to back up systems with irregular backup needs, such as laptops? That allows you to run scripts before or after the backup job? That provides browsing capabilities so you can decide upon a restore point? Bacula may be what you're looking for.
Introducing Bacula
Bacula is a client-server solution composed of several distinct parts:

Director
The Director is the most complex part of the system. It keeps track of all clients and files to be backed up. This daemon talks to the clients and to the storage devices.

Client/File Daemon
The Client (or File) Daemon runs on each computer which will be backed up by the Director. Some other backup solutions refer to this as the Agent.

Storage Daemon
The Storage Daemon communicates with the backup device, which may be tape or disk.

Console
The Console is the primary interface between you and the Director. I use the command-line Console, but there is also a GNOME GUI Console.
Each File Daemon will have an entry in the Director configuration file. Other important entries include FileSets and Jobs. A FileSet identifies a set of files to back up. A Job specifies a single FileSet, the type of backup (incremental, full, etc.), when to do the backup, and what Storage Device to use. Backup and restore jobs can be run automatically or manually.
Installation
Bacula stores details of each backup in a database. You can use either SQLite or MySQL, and starting with Bacula Version 1.33, PostgreSQL. Before you install Bacula, decide which database you want to use.
The existing Bacula documentation provides detailed installation instructions if you're installing from source. To install instead the SQLite version of the FreeBSD port:
# cd /usr/ports/sysutils/bacula

# make install

Or, if you prefer to install the MySQL version:
# cd /usr/ports/sysutils/bacula

# make -DWITH_MYSQL install

Configuration Files
Bacula installs several configuration files that should work for your environment with few modifications.
File Daemon on the backup client
The first configuration file, /usr/local/etc/bacula-fd.conf, is for the File Daemon. This file needs to reside on each machine you want to back up. For security reasons, only the Directors specified in this file will be able to communicate with this File Daemon. The name and password specified in the Director resource must be supplied by any connecting Director.
You can specify more than one Director { } resource. Make sure the password matches the one in the Client resource in the Director's configuration file.
The FileDaemon { } resource identifies this system and specifies the port on which it will listen for Directors. You may have to create a directory manually to match the one specified by the Working Directory.
Storage Daemon on the backup server
The next configuration file, /usr/local/etc/bacula-sd.conf, is for the Storage Daemon. The default values should work unless you need to specify additional storage devices.
As with the File Daemon, the Director { } resource specifies the Director(s) that may contact this Storage Daemon. The password must match that found in the Storage resource in the Director's configuration file.
Director on the backup server
The Director's configuration is by necessity the largest of the daemons. Each Client, Job, FileSet, and Storage Device is defined in this file.
In the following example configuration, I've defined the Job Client1 to back up the files defined by the FileSet Full Set on a laptop. The backup will be performed to the File storage device, which is really a disk located at laptop.example.org.

# more /usr/local/etc/bacula-dir.conf



Director {

Name = laptop-dir

DIRport = 9101

QueryFile = "/usr/local/etc/query.sql"

WorkingDirectory = "/var/db/bacula"

PidDirectory = "/var/run"

Maximum Concurrent Jobs = 1

Password = "lLftflC4QtgZnWEB6vAGcOuSL3T6n+P7jeH+HtQOCWwV"

Messages = Standard

}

Job {

Name = "Client1"

Type = Backup

Client = laptop-fd

FileSet = "Full Set"

Schedule = "WeeklyCycle"

Storage = File

Messages = Standard

Pool = Default

Write Bootstrap = "/var/db/bacula/Client1.bsr"

Priority = 10

}

FileSet {

Name = "Full Set"

Include = signature=MD5 {

/usr/ports/sysutils/bacula/work/bacula-1.32c

}



# If you backup the root directory, the following two excluded

# files can be useful

#

Exclude = { /proc /tmp /.journal /.fsck }

}

Client {

Name = laptop-fd

Address = laptop.example.org

FDPort = 9102

Catalog = MyCatalog

Password = "laptop-client-password"

File Retention = 30 days

Job Retention = 6 months

AutoPrune = yes

}

# Definition of file storage device

Storage {

Name = File

Address = laptop.example.org

SDPort = 9103

Password = "TlDGBjTWkjTS/0HNMPF8ROacI3KlgIUZllY6NS7+gyUp"

Device = FileStorage

Media Type = File

}

Note that the password given by any connecting Console must match the one here.

No comments:

 
Custom Search