System backup is a complicated task, including backup, keep trace of record and restore. As the most simple method, you may just *.tar.gz your data and rsync them to remote storage. This maybe useful when you have only 1 server with simple backup architecture, but for sure not enough if you have number of production server with GB scale backup. Therefore Bacula (http://www.bacula.org/) show be your cup of tea.
From Bacula (http://www.bacula.org/):
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.
Bacula split all roles within backup procedure into a very detail and elegant style, so once you understand how its work, you will never get lose. It also support number of backup storage devices, e.g. harddisk, tap, DVD, USB flash driver and so on. It even support different type of database backend, e.g. MySQL, PostgreSQL and SQLite. Moreover, you can setup email report whenever backup process is complete, or browse backup statistic though a simple but elegant web interface. Long story short: it is a fairly complete backup solution that a system administrator should learn about it :-)
This mini-HOWTO will guide you though the installation and configuration of Bacula on top of Debian sid, setup the web GUI for report, and some basic daily operation.
Install required packages
May I assume that you understand how to configure your Debian box as sid correctly? If no, please refer to here.
Once again, I will assume that you have install and configure Apache, MySQL and PHP5 correctly, which will not mentioned within this document. It is recommended to have phpMyAdmin installed in your server for handy web-based management, too.
Why don't we install Debian etch Bacula packages, but from sid? It is mainly because of packages version: etch coming with version 1.38 where sid with 2.2.8. As you may install Bacula as servers in Debian, but serve some remote client that other than Debian (e.g. RedHat, SUSE, Solaris, MS Windows, or even Mac OSX), install Bacula client ONLY on your remote client is very simple and strict forward, especially install them from tarball. Therefore you may hope to use the latest tarball from official site for remote client, and so your server should be updated version, too.
Install Bacula on Debian sid is just as simple as APT command:
apt-get update
apt-get install bacula bacula-director-mysql bacula-sd-mysql bacula-docWhen asking for database configuration, answer "skip configuration now" and let's handle it manually within next section.
What if I hope to use Debian etch, but only install Bacula as sid? Refer to above APT source configuration, just PIN your Debian box as stable, install Bacula from aptitude, and manually handle the packages version of Bacula as sid. You will need more effort for this style with training, so I will not detail the procedure in here.
Setup database
Bacula highly relay on database record, which used to keep trace file update record, storage management, job status and result, and so on. Here we will use MySQL as database backend.
There is a handy wrapper script for required database creation. Run /usr/share/bacula-director/make_mysql_tables -uroot -p, answer your MySQL administrator password, and let the job get done.
Next, we should create a specific database user account for Bacula, with restricted privilege. I will not detail this procedure within this document, please use whatever tools/skill for this target. Let's say we create a user account called as "bacula" with password "CHANGE".
Configure Bacula FD (File Daemon)
Bacula FD (File Daemon) is somehow can understand as "client": a daemon that install in remote computer, receive instruction from director daemon, capture local files, and send to SD (Storage Daemon).
There is not much configuration for FD, but still need to consider some minor points. Check your /etc/bacula/bacula-fd.conf:
FileDaemon-
If this server will be instructed by some remote directors, remember to configure its
FDAddressas0.0.0.0(or some other suitable values).
Director-
This section define the allowed directors. Be careful that the
Passwordshould be the same as that inClientsection of director configuration (will be detail in later sections).
Configure Bacula SD (Storage Daemon)
Bacula SD (Storage Daemon) handle your storage devices, e.g. file, tape, DVD, USB and so on. For the most common case on today, you should at least configure your file storage correctly, as harddisk is now very large and cheap :-)
In case of SD, check your /etc/bacula/bacula-sd.conf and be careful for:
Device-
Debian have default setup the template named as "FileStorage" for you, BUT it is not configure correctly. Check the
Archive Deviceand check it as a suitable values, e.g./var/backups/bacula.
Storage-
Similar as FD, change
SDAddressif you hope to connect this storage daemon from remote director (well... usually you will need to install both director and storage daemon together... so this may not be too common...).
Director-
Again, similar as the case of that in FD.
Extra tips: the default behavior of file storage is in non-stop no-maximum-limit style, which means the backup file will keep on rollup, even up to TB scale! Sounds too crazy, isn't it? So add a special parameter within
Devicesection will give you a magical effect, which split each backup file into size of DVD:
Maximum Volume Size = 4700000000
You should combine this skill with automatically volume labeling (will detail in later sections).
Configure Bacula director daemon
Okay so now let's start with Bacula's sprite: the director daemon. The director will handle the schedule of backup, define the directories/files for backup, manage the use of storage target, handle the list of client machines, and even handle email notify when job complete. You may seems director daemon as the "brain" of Bacula :-)
Let's check the /etc/bacula/bacula-dir.conf and configure it:
JobDefs-
This is the basic template of backup jobs. You can further override this default value in detail job definition.
Job-
Inheritance settings from
JobDefs, with local configuration. You should change the default "Client1" as your hostname, e.g. www.example.com. In case of "RestoreFiles", you should also change theWhereas:
Where = /var/backups/bacula/bacula-restores
In case of "BackupCatalog", you should also change theRunBeforeJobas:
RunBeforeJob = "/etc/bacula/scripts/make_catalog_backup bacula bacula 'CHANGE' localhost"
FileSet
-
Very Important! Remove the default
/build/buildd/bacula-2.2.8/debian/tmp-build-sqliteline and add the following (or other directories that you are interested in):
File = /etc
File = /home
File = /var/log
File = /var/www
File = /var/backups
Remember to add this line underExcludesection:
File = /var/backups/bacula
Client-
Do you remember the
JobDefandJobsection? They have a parameter called asClient, and so here you will define what is it, or better say define how to connect to our target backup client. Usually I will change the name of catalog as their type, e.g. "MySQL". Don't forget to configure thatPasswordas that defined in your remote client's FD configuration. Storage-
Similar as above
Clientsection, define our target storage daemon, and use what device as it provided. Remember to configurePasswordas what you defined in your SD configuration, too.
Catalog-
Sorry that I hate the name of "MyCatalog" (meaningless...), so usually I will change it as "MySQL". Remember to update the configuration as your database setup:
dbname = bacula; DB Address = ""; user = bacula; password = "CHANGE"
Pool-
Very Important! Remember to add this line so auto volume labeling can take action correctly:
Label Format = "${Pool}_${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}h${Minute:p/2/0/r}m"
Restart services and check your setup
It's time to check your configuration. Let's run the following command and restart all of the Bacula related services:
find /etc/init.d/ -name 'bacula*' -exec {} restart \;Run ps aux | grep bacula and should have similar result:
root 12607 0.0 0.0 43612 920 ? Ssl 12:14 0:00 /usr/sbin/bacula-fd -c /etc/bacula/bacula-fd.conf
bacula 12618 0.0 0.0 54612 1996 ? Ssl 12:14 0:00 /usr/sbin/bacula-dir -c /etc/bacula/bacula-dir.conf -u bacula -g bacula
bacula 12631 0.0 0.0 58208 1412 ? Ssl 12:14 0:00 /usr/sbin/bacula-sd -c /etc/bacula/bacula-sd.conf -u bacula -g tapeRun netstat -utal | grep bacula and should have similar result:
tcp 0 0 localhost.lo:bacula-dir *:* LISTEN
tcp 0 0 localhost.loc:bacula-fd *:* LISTEN
tcp 0 0 localhost.loc:bacula-sd *:* LISTENRun bacula-console for the console administration interface. If you setup Bacula correctly you should able to turn it on. Within the administrator console, try the following commands:
status client: check the status of all available predefined clients.status storage: check the status of your available storage devices.list pool: remember to check if theLabelFormatis setup correctly.estimate: estimate the backup process, and list the expected backup size.
Take your first Bacula backup
If all of the above are working fine, it is time for us to enjoy the powerful of Bacula. Just start the Bacula console with bacula-console.
After log into the console, your first command should be help. Here are a list of most important commands:
delete delete [pool=<pool-name> | media volume=<volume-name>]
estimate performs FileSet estimate, listing gives full listing
help print this command
list list [pools | jobs | jobtotals | media <pool=pool-name> | files <jobid=nn>]; from catalog
messages messages
quit quit
restore restore files
run run <job-name>
status status [storage | client]=<name>What we need to do for now is run. Type run and you will need to specific your target job:
A job name must be specified.
The defined Job resources are:
1: www.example.com
2: BackupCatalog
3: RestoreFiles
Select Job resource (1-3):Just answer the question and Bacula will start its work. You can keep trace its status with message.
After the backup is complete, you can check its result with list jobs:
+-------+-------------------+---------------------+------+-------+----------+---------------+-----------+
| JobId | Name | StartTime | Type | Level | JobFiles | JobBytes | JobStatus |
+-------+-------------------+---------------------+------+-------+----------+---------------+-----------+
| 2 | www.example.com | 2008-06-04 15:12:59 | B | F | 63,375 | 9,901,128,984 | T |
+-------+-------------------+---------------------+------+-------+----------+---------------+-----------+Simply hit quit to exit bacula-console. You may also interesting in your backup result, so just give a ls -la /var/backups/bacula and you will see the file generated:
-rw-r----- 1 bacula tape 4699957436 2008-06-04 15:15 Default_2008-06-04_15h12m
-rw-r----- 1 bacula tape 4699957287 2008-06-04 15:20 Default_2008-06-04_15h15m
-rw-r----- 1 bacula tape 520375396 2008-06-04 15:21 Default_2008-06-04_15h20mTake your first Bacula restore
Well, restore is much simpler then backup, but still need some tricky skill. First of all, log into bacula-console and give a hit of restore:
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 comma separated 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: Find the JobIds of the most recent backup for a client
10: Find the JobIds for a backup for a client before a specified time
11: Enter a list of directories to restore for found JobIds
12: CancelWhat you must understand are options 5 & 6. Let's say if we hope to restore a file from most recent backup, click 5 and you will ask for target client (if you have more than 1 client). Now you will have a very simple console, which use for restore file selection:
You have selected the following JobId: 2
Building directory tree for JobId 2 ... ++++++++++++++++++++++++++++++++++++++++++
1 Job, 53,370 files inserted into the tree.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /Always, Always type help to get the support information:
Command Description
======= ===========
cd change current directory
count count marked files in and below the cd
dir long list current directory, wildcards allowed
done leave file selection mode
estimate estimate restore size
exit same as done command
find find files, wildcards allowed
help print help
ls list current directory, wildcards allowed
lsmark list the marked files in and below the cd
mark mark dir/file to be restored recursively, wildcards allowed
markdir mark directory name to be restored (no files)
pwd print current working directory
unmark unmark dir/file to be restored recursively in dir
unmarkdir unmark directory name only no recursion
quit quit and do not do restore
? print helpSo your procedure are: 1. use ls and cd to go to your target directory, 2. use mark to select directories/files for restore, 3. type done and process the restore action.
As we have predefined the restore location as /var/backups/bacula/bacula-restores (recall the setup of job "RestoreFiles"), now your files are located there. Just feel free to handle your backup copy as what you like :-)
Install bacula-web interface
So now your Bacula is running smoothly; as predefined schedule, your system will now having full backup on every month first Sunday, defferential backup on the rest of Sunday, and daily incremental backup, too. But that may be too complicated if we always need to keep trace the backup jobs status with CLI, any better solution? Yes, and you may choose bacula-web
bacula-web is one of the official GUI of Bacula, comming from bacula-gui package. I will suggest you to obtain this package from official home page, and install it from tarball. Go to http://sourceforge.net/projects/bacula/ and download it from package bacula (e.g. bacula-gui-2.2.8.tar.gz).
I will assume you have Apache2.2 setup with PHP5, and document root at /var/www/. Extract the tarball to there, and setup the symbolic linkage:
tar zxvf bacula-gui-2.2.8.tar.gz -C /var/www/
ln -s /var/www/bacula-gui-2.2.8/bacula-web /var/www/The only thing you need to do with bacula-web is configure the database connection, as like as that for Bacula director daemon. Edit /var/www/bacula-web/configs/bacula.conf as:
host = localhost
login = bacula
pass = "CHANGE"
db_name = bacula
db_type = mysqlFirst of all, access the testing page of bacula-web (e.g. http://www.example.com/bacula-web/test.php), run the test and check its result. Then access your web interface (e.g. http://www.example.com/bacula-web/) and check your backup statistics :-)


















Can't conect to mysql
When I try the command:
:~# /usr/share/bacula-director/make_mysql_tables -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Creation of Bacula MySQL tables failed.
What can I do?
Are you sure that your MySQL
Are you sure that your MySQL is already setup and running correctly?
If you have phpMyAdmin installed, test with it;
if you are able to access though console, try
mysql -u root -pdirectly;check if your MySQL are running with
ps aux | grep mysql;check if UNIX socket file exist with
ls -la /var/run/mysqld/mysqld.sock;check content of MySQL error log with
cat /var/log/mysql.err;check... let me think for a bit while :S
----------------------------------------
Edison Wong
It's because no database with
It's because no database with a name "bacula" is created yet. As the dbconfig-common at the moment has a bug in bacula's configuration, the only way of doing it is to manually create a database "bacula":
mysql -u root -p
(enter-your-root-password)
mysql> create database bacula;
And then create a user with all privileges for that database:
mysql> GRANT ALL PRIVILEGES ON bacula.* TO 'bacula'@'localhost' IDENTIFIED BY 'password';
mysql> flush privileges;
mysql> exit
Bacula Systems wants to Thank You, and support our community!
Thanks for mentioning Bacula! We really appreciate the members of our community who offert tips and help to others! www.baculasystems.com was started by project manager Kern Sibbald to (1)make sure Bacula stays free open source, (2)make some money to fund ongoing Bacula development, all open source, (3)provide guaranteed high quality support and training to commercial, production users of Bacula.
Comments and feedback welcome!
Jack
jack.griffin@baculasystems.com
Thanks for your positive
Thanks for your positive comment. It is my pleasure for having reply from CEO of www.baculasystems.com directly.
I would like to contribute for Bacula, too. My Linux, C/C++, Perl and PHP skills are always ready for Bacula :D
----------------------------------------
Edison Wong
Post new comment