With this article I want you to show how to install bacula from source and how to create a basic configuration. The topics in this artice will be the following:
Install bacula from source under Solaris 10 x86
Create the bacula database under Slackware Linux 13.1
Configure the bacula director
Configure the bacula storage daemon
Configure the bacula file daemon
First start
Configure the bacula console
Run a backup job
Run a restore job
The installation of bacula should work very similar under any Unix/Linux. If you have only one machine available then you can run bacula and mysql on it, you don't need seperate machines for it. Also this article is a very simple description, I don't explain all options that I am using here (and mostly I am using the default settings created during the installation). For details look in to the documentation provided on http://www.bacula.org.
Install bacula from source under Solaris 10 x86
Before you begin you should install a proper mysql package. I like to use the mysql from the blastwave repositories, see http://www.blastwave.org for details. Also make sure that you have /usr/sfw and /usr/ccs in your PATH variable, eg:
# export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/sfw/sbin:/usr/ccs/bin:/opt/csw/bin:/opt/csw/sbin
The above PATH variable is my current setting. When you have installed a useable mysql package then download the latest source release from http://www.bacula.org. When the download has finished extract the source under /usr/src:
# cd /usr/src
# gunzip -dc bacula-5.2.3.tar.gz | tar xf -
Next run the configure script, compile the sources and install the binaries. Don't forget to set the appropiate mysql path when executing the configure script:
# ./configure --prefix=/opt/bacula/5.2.3 --with-mysql=/opt/csw/mysql5
...
# make
...
# make install
...
If everyting has compiled then you should have the binaries under /
# ls /opt/bacula/5.2.3/sbin/
...
bacula-fd
bacula-dir
bacula-sd
...
The last step is to create a symbolic link. Thet will make it easier to handle multiple bacula version (eg. updates etc):
# cd /opt/bacula
# ln -s 5.2.3 latest
bacula is now compiled and installed.
Create the bacula database under Slackware Linux 13.1
You are ready now to install the database. First login into your database server (when the bacula server is not the database server like mine) and connect to mysql as root:
# mysql -u root -p
Enter password:
...
Create the bacula database and exit:
mysql> create database bacula;
Query OK, 1 row affected (0.00 sec)
mysql> exit
To create the tables inside the database use the shipped make_mysql_tables within the sources:
# cd /usr/src/bacula-5.2.3/src/cats
# sh make_mysql_tables -p
Enter password:
Creation of Bacula MySQL tables succeeded.
With the -p option mysql will ask for a password. Finally try to connect from the bacula server to the database server as user bacula:
# /opt/csw/mysql5/bin/mysql -u bacula -h 192.168.1.73 -p
Enter password:
...
That's it, the creation of the database has finished.
Configure the bacula director
Before you begin with the configuration drop the installed configuration. Don't delete it just move it to another place:
# cd /opt/bacula/latest/etc
# mkdir orig
# mv * orig/
Now begin to configure the bacula director. The bacula director holds all configuration about the jobs, schedules, available storage and file daemons and so on. I try to split the configuration file, hopefully it will make the configuration not too hard. First create the bacula-dir.conf in /opt/bacula/latest/etc:
# cd /opt/bacula/latest/etc
# vi bacula-dir.conf
Director {
Name = bck01-dir
DIRport = 9101
QueryFile = "/opt/bacula/5.2.3/etc/query.sql"
WorkingDirectory = "/opt/bacula/5.2.3/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "mlaO4VoMtSztiaYYho4JBiLc2QIWbe2+os6c+5MmDyfT"
Messages = Daemon
}
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "bacula"; DB Address = "192.168.1.73"
}
Console {
Name = bck01-mon
Password = "Q1WBj91S2bJExh4xuXjfAB0tHQqkYZThrgsktrWqY+nQ"
CommandACL = status, .status
}
# JOBS
@/opt/bacula/latest/etc/common/jobs.conf
# FILESETS
@/opt/bacula/latest/etc/common/fileset.conf
# SCHEDULES
@/opt/bacula/latest/etc/common/schedule.conf
# MESSAGES
@/opt/bacula/latest/etc/common/message.conf
# CLIENTS AND STORAGE DAEMONS
@/opt/bacula/latest/etc/common/client.conf
@/opt/bacula/latest/etc/common/storage.conf
# VOLUME POOLS
@/opt/bacula/latest/etc/common/pool.conf
The first section 'Director' has some basic configuration about the director itself, like the name, working directory etc. The second section 'Catalog' contains the database configuration. The third section 'Console' is for the program bconsole. bconsole is used to interact with bacule (coming later). The last lines beginning with the @ include more files available under /opt/bacula/latest/etc/common/. To continue create the directory and change into it:
# mkdir /opt/bacula/latest/etc/common
# cd /opt/bacula/latest/etc/common
Now create jobs.conf file:
# vi jobs.conf
Job {
Name = "BackupCatalog"
Type = Backup
Client = bck01-fd
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/local/bacula_bootstrap/%c.%n.bsr"
Level = Full
FileSet="Catalog"
RunBeforeJob = "/opt/bacula/5.2.3/etc/scripts/make_catalog_backup.pl MyCatalog"
RunAfterJob = "/opt/bacula/5.2.3/etc/scripts/delete_catalog_backup"
Priority = 11
}
Job {
Name = "RestoreFiles"
Type = Restore
Client=bck01-fd
FileSet="Catalog"
Storage = File
Pool = File
Messages = Standard
Where = /local/bacula-restores
}
The file above defines the jobs. In this case two jobs are defined, one job for backing up the catalog and another job to restore. The BackupCatalog job contains some configuration about the client, schedule, which storage to use etc. Very important for the backup job is the bootstrap. In this case I have added a dedicated location for saving the bootstraps. Each job needs a bootstrap otherwise a restore job will not work. Important for the RestoreFiles job is the Where option. When ever you run a restore job then all files will be restored under the given directory. Now continue with the fileset.conf file:
# vi fileset.conf
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/opt/bacula/5.2.3/var/bacula/working/bacula.sql"
}
}
The Catalog fileset has only on file which is /opt/bacula/5.2.3/var/bacula/working/bacula.sql. When take a look in the jobs.conf file then you will notice the RunBeforeJob option. This options runs a script that creates a mysql dump of the bacula database which will be stored as /opt/bacula/5.2.3/var/bacula/working/bacula.sql and backup by bacula. The next file will be the schedule.conf file, it holds all schedules when to perform a backup:
# vi schedule.conf
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sun at 23:05
Run = Incremental mon-sat at 23:05
}
The schedule above will run a full backup on sunday and incremental backups the other days.
Then create the configuration file for the messages:
# vi message.conf
Messages {
Name = Standard
mailcommand = "/opt/bacula/5.2.3/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/opt/bacula/5.2.3/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/opt/bacula/5.2.3/var/bacula/working/log" = all, !skipped
catalog = all
}
Messages {
Name = Daemon
mailcommand = "/opt/bacula/5.2.3/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/opt/bacula/5.2.3/var/bacula/working/log" = all, !skipped
}
The message.conf file defines who to inform when a special event happened, eg. who must informed when backup failed etc. The next file defines all clients:
# vi client.conf
Client {
Name = bck01-fd
Address = bck01
FDPort = 9102
Catalog = MyCatalog
Password = "3DaL1f6SxjlcVzxyURu+Q+IJNvcpG3y1vqwsItCWW8Cd"
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}
In this only one client is available and that is the director itself. The storage.conf file looks pretty much the same:
# vi storage.conf
Storage {
Name = File
Address = bck01
SDPort = 9103
Password = "QLBrhBa8ebxbTjWwy74qIfvPlTFN44dCfmymfmmL41i8"
Device = FileStorage
Media Type = File
}
This file defines which storage is available on which system, eg. you could have a tape library available on a different host. Then the storage daemon would get an entry in this file, but the configuration for the storage would be on the specific host. Finally the last file is the configuration file for the pool:
# vi pool.conf
Pool {
Name = File
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
Maximum Volume Bytes = 50G
Maximum Volumes = 100
}
In this case only one pool is defined and it is for the file storage. You can define several pools for more or less critical data to avoid that critical backups get overwritten by less critical backups.
All the above configuration files are only for the director. I hope that this is not to difficult. Keep in mind that have to define a job for a client with a fileset. The job needs a schedule and storage to write to. The storage must have a pool with media available. In case that something unforseen happened then somebody needs to get a message.
Configure the bacula storage daemon
To configure the bacula storage daemon change into the etc directory and create the bacula-sd.conf file:
# cd /opt/bacula/latest/etc
# vi bacula-sd.conf
Storage {
Name = bck01-sd
SDPort = 9103
WorkingDirectory = "/opt/bacula/5.2.3/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director {
Name = bck01-dir
Password = "QLBrhBa8ebxbTjWwy74qIfvPlTFN44dCfmymfmmL41i8"
}
Messages {
Name = Standard
director = bck01-dir = all
}
Device {
Name = FileStorage
Media Type = File
Archive Device = /local/bacula_storage
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}
The file above is very simple. The first three sections are defining the storage daemon, the director and how to send messages. The last section is the storage device itself. In this case it is file storage known from bacula director configuration. All backups will be written to /local/bacula_storage (after labeling one media).
Configure the bacula file daemon
The file daemon is typically used to configure a client. Everytime you want to add a client you have to configure the bacula-fd.conf file:
# cd /opt/bacula/latest/etc
# vi bacula-fd.conf
Director {
Name = bck01-dir
Password = "3DaL1f6SxjlcVzxyURu+Q+IJNvcpG3y1vqwsItCWW8Cd"
}
Messages {
Name = Standard
director = bck01-dir = all, !skipped, !restored
}
FileDaemon {
Name = bck01-fd
FDport = 9102
WorkingDirectory = /opt/bacula/5.2.3/var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
This file contains three sections for the director, the messages and the client it self.
First start
After the basic configuration from above (I hope you made it so far) you are ready for a first start. First start the storage daemon, then the file daemon and at least the director:
# /opt/bacula/latest/sbin/bacula-sd -c /opt/bacula/latest/etc/bacula-sd.conf
# /opt/bacula/latest/sbin/bacula-fd -c /opt/bacula/latest/etc/bacula-fd.conf
# /opt/bacula/latest/sbin/bacula-dir -c /opt/bacula/latest/etc/bacula-dir.conf
Check that all daemons are up and running:
# pgrep -fl bacula
1359 /opt/bacula/latest/sbin/bacula-dir -c /opt/bacula/latest/etc/bacula-dir.conf
1423 /opt/bacula/latest/sbin/bacula-sd -c /opt/bacula/latest/etc/bacula-sd.conf
1420 /opt/bacula/latest/sbin/bacula-fd -c /opt/bacula/latest/etc/bacula-fd.conf
If you have trouble getting one of the daemons to start then use the debug option, eg:
# /opt/bacula/latest/sbin/bacula-dir -d 1 -c /opt/bacula/latest/etc/bacula-dir.conf
Configure the bacula console
To interact with bacula you have to use bconsole. Of course it needs it's own configuration file:
# cd /opt/bacula/latest/etc
# vi bconsole.conf
Director {
Name = bck01-dir
DIRport = 9101
address = bck01
Password = "mlaO4VoMtSztiaYYho4JBiLc2QIWbe2+os6c+5MmDyfT"
}
Luckily it just needs to know how to reach the director. Now start the console:
# /opt/bacula/latest/sbin/bconsole -c /opt/bacula/latest/etc/bconsole.conf
Connecting to Director bck01:9101
1000 OK: bck01-dir Version: 5.2.3 (16 December 2011)
Enter a period to cancel a command.
*
Run a backup job
Before you can run a job now you have to label the media on the file storage. You only have to do this once. If your media get's full then you need to label another media:
*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: File
Enter new Volume name: file01
Connecting to Storage daemon File at bck01:9103 ...
Sending label command for Volume "file01" Slot 0 ...
3000 OK label. VolBytes=188 DVD=0 Volume="file01" Device="FileStorage" (/local/bacula_storage)
Catalog record for Volume "file01", Slot 0 successfully created.
Requesting to mount FileStorage ...
3001 OK mount requested. Device="FileStorage" (/local/bacula_storage)
To start a job use the run command:
*run
A job name must be specified.
The defined Job resources are:
1: BackupCatalog
2: RestoreFiles
Select Job resource (1-2): 1
Run Backup job
...
OK to run? (yes/mod/no): yes
Job queued. JobId=6
...
Termination: Backup OK
...
When you get a message similar to the one above then the backup of the catalog database was succesfull.
Run a restore job:
More important then having a backup is to perform a restore (I know a lot people with a working backup and a unknown restore situation). You have various possibilities to restore a file. Currently I only have a backup of the bacula database dump so this is the only file I can restore until now. To restore it start bconsole again and use the restore command:
*restore
...
To select the JobIds, you have the following choices:
...
7: Enter a list of files to restore
...
Select item: (1-13): 7
...
Enter full filename: /opt/bacula/5.2.3/var/bacula/working/bacula.sql
Enter full filename:
...
1 file selected to be restored.
Run Restore job
JobName: RestoreFiles
...
OK to run? (yes/mod/no): yes
Job queued. JobId=8
...
Termination: Restore OK
After all this I hope you will be able to perform a backup and a restore.
thnx so much for this how to.
ReplyDeletei wanna install just the bacula client from source under solaris 10 x86.
can anyone help me ?
Take a look at this one: http://karellen.blogspot.de/2012/01/add-new-bacula-client.html
ReplyDeleteTo make it short: ./configure --prefix=/opt/bacula/5.2.3 --enable-client-only
hi karl,
ReplyDeletei have complie the bacula client, and i have start the daemon from this command :
# /opt/bacula/latest/sbin/bacula-fd -c /opt/bacula/latest/etc/bacula-fd.conf
but how can i start the bacula fd daemon in the startup with the system ?
For Solaris you need to create a manifest to define your service, see: http://www.oracle.com/technetwork/systems/articles/smf-example-jsp-136458.html
Delete