Bacula is a very powerful enterprise level backup solution which can backup localhost, and even remote host via network. It has these components
- Director
- Storage server
- Cateloge – Database server
- Console Server
The installation process is pretty straight forward in Redhat Linux or CentOS. The OS that I used in my lab is CentOS 7. I am sure it will be similar on others Redhat and CentOS systems too
Let us begin by installing all required packages in an updated CentOS system
#] yum install -y bacula-director bacula-storage bacula-console bacula-client mariadb-server
Let us start the DB server
#] systemctl start mariadb
Let us granted user bacula Privileges on database by running a scrip that got installed when other packages were installed
#] /usr/libexec/bacula/grant_mysql_privileges
Let us create bacula databases using the pre-istalled script
#] /usr/libexec/bacula/create_mysql_database -u root
Let us create the tables used by bacula using the pre-installed script
#] /usr/libexec/bacula/make_mysql_tables -u bacula
Secure the Database server by assigning a Root Password and leaving the remaining option with default value
#]mysql_secure_installation
Let us assign a password for the root user in MariaDB server. Login to the server as root and run the following command:
DB> UPDATE mysql.user SET Password=PASSWORD(‘my_bacula_pw’) WHERE User=’bacula’;
Let us flush the user privileges in the DB server
DB> FLUSH PRIVILEGES;
Exit from MySQL console
Let us ensure the database server starts during the startup of the host
#] systemctl enable mariadb
By default bacula is set to use the PostgreSQL. The the following command is used to enable MySQL as the default. When you get the menu, select 1
#] alternatives –config libbaccats.so
Let us make a two folders in the server. This is where we can plan to backup and restore files and folders. Ensure this is in a partition that has huge space to store all backups
#] mkdir -p /bacula/backup /bacula/restore
Let us assign the correct permissions
#] chown -R bacula:bacula /bacula
#] chmod -R 700 /bacula
The server installation and setup is kind of done. Now we need to configure the server.
We will start with the Director.
Open the file bacula-dir.conf using an editor
Ensure the last line is added to the below block
Director { # define myself
Name = bacula-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = “/etc/bacula/query.sql”
WorkingDirectory = “/var/spool/bacula”
PidDirectory = “/var/run”
Maximum Concurrent Jobs = 1
Password = “@@DIR_PASSWORD@@” # Console password
Messages = Daemon
DirAddress = 127.0.0.1
}
===== ==
Now we need to create a “Job” to backup the localhost. Find the Name parameter in defined Job that reads “BackupClient1” and replace it with “BackupLocalFiles”
== === =
Job {
#Name = “BackupClient1”
Name = “BackupLocalFiles“
JobDefs = “DefaultJob”
}
== === =
Now you may want to change the default location of where files should be restored from “/tmp/bacula-restores” to “/bacula/restore” and change the Job name “RestoreFiles” to “RestoreLocalFiles” so that it make meaning.
====== =====
Job {
Name = “RestoreLocalFiles”
Type = Restore
Client=BackupServer-fd
FileSet=”Full Set”
Storage = File
Pool = Default
Messages = Standard
Where = /bacula/restore
}
====== =====
You may want to edit the FileSet, named “Full Set” that defines the files that needs to be backed from the localhost. In this example we will backup the folder /home/user1. Ensure gzip compression is used, and only /home folder is backed.
======================= ======
FileSet {
Name = “Full Set”
Include {
Options {
signature = MD5
compression = GZIP
}
File = /data
}
Exclude {
File = /bacula
}
}
======================= ======
In the Storage parameter with name as “File” ensure the address parameter has the value as the actual hostname resolvable to an IP by the localhost. Ensure we do not use the value “localhost”. My host’s FQN is myhost.mydomain.local
===== ==== ===
Storage {
Name = File
# Do not use “localhost” here
Address = myhost.mydomain.local # N.B. Use a fully qualified name here
SDPort = 9103
Password = “@@SD_PASSWORD@@”
Device = FileStorage
Media Type = File
}
===== ==== ===
In the catelog section named “MyCatalog” ensure the correct password for for the dbname, dbuser and password is used
====*====== ===
Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = “dbi:postgresql”; dbaddress = 127.0.0.1; dbport =
dbname = “bacula“; dbuser = “bacula“; dbpassword = “my_bacula_pw“
}
====*====== ===
In the Pool definition named “File”, it will be good to use a “Label Format” parameter to identify the host that is stored. For example “myLocalhost-”
===== === == ==== ==
Pool {
Name = File
Pool Type = Backup
Label Format = myLocalhost-
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
}
===== === == ==== ==
Now we are in a position to check if there are any syntax error in the configuration file by running the following command:
]# sudo bacula-dir -tc /etc/bacula/bacula-dir.conf
Check for any error message
**************** Storage Daemon configuration ************
The configuration file for the storage daemon is bacula-sd.conf. Since the storage server is also the same server, add the hostname of the same server in Storage parameter named “BackupServer-sd”. This is done by adding a line “SDAddress = myhost.mydomain.local”
==== === === ===
Storage { # definition of myself
Name = BackupServer-sd
SDPort = 9103 # Director’s port
WorkingDirectory = “/var/lib/bacula”
Pid Directory = “/var/run/bacula”
Maximum Concurrent Jobs = 20
SDAddress = myhost.mydomain.local
}
==== === === ===
In the Device parameter named “FileStorage” ensure the place where backup is stored is changed to “Archive Device = /bacula/backup”
=== === === ===
Device {
Name = FileStorage
Media Type = File
Archive Device = /bacula/backup
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}
=== === === ===
Now verify the storage configuration:
# sudo bacula-sd -tc /etc/bacula/bacula-sd.conf
Now it is time to change bacula-dir passwords used in files.
]# sudo sed -i “s/@@DIR_PASSWORD@@/my_bacula_pw/” /etc/bacula/bacula-dir.conf
]# sudo sed -i “s/@@DIR_PASSWORD@@/my_bacula_pw/” /etc/bacula/bconsole.conf
]# sudo sed -i “s/@@SD_PASSWORD@@/my_bacula_pw/” /etc/bacula/bacula-sd.conf
]# sudo sed -i “s/@@SD_PASSWORD@@/my_bacula_pw/” /etc/bacula/bacula-dir.conf
]# sudo sed -i “s/@@FD_PASSWORD@@/my_bacula_pw/” /etc/bacula/bacula-dir.conf
]# sudo sed -i “s/@@FD_PASSWORD@@/my_bacula_pw/” /etc/bacula/bacula-fd.conf
======************=======
Now we are ready to start Bacula
]# sudo systemctl start bacula-dir
]# sudo systemctl start bacula-sd
]# sudo systemctl start bacula-fd
]# sudo systemctl enable bacula-dir
]# sudo systemctl enable bacula-sd
]# sudo systemctl enable bacula-fd
******* ******* ********
Installation is complete now you can start managing the backup application by using the
IMP :Volume Retention : As a consequence, the minimum Volume Retention period should be at twice the interval of your Full backups.
Process to test backup and restore can be found “here“