Bacula: Instructions and Configuration Files For Installing and Using Bacula, An Open Source Backup Solution
Bacula: Instructions and Configuration Files For Installing and Using Bacula, An Open Source Backup Solution
Table of Contents
NOTES
SET UP THE SERVER ENVIRONMENT
SET UP THE BACULA ENVIRONMENT
INSTALL BACULA
CONFIGURE POSTGRESQL
CONFIGURE bacula-dir.conf
CONFIGURE bacula-sd.conf
START & ENABLE COMPONENTS
TEST CONSOLE FUNCTIONALITY
TEST LOCAL BACKUP & RESTORE
INSTALL & CONFIGURE CLIENT
ADD FILE SETS (ON SERVER)
ADD CLIENT RESOURCE
TEST SERVER-CLIENT CONNECTION
TEST BACKUP JOB FOR CLIENT
TEST RESTORE OPERATION FOR CLIENT
OPTIONAL: INSTALL BACULUM GUI
NOTES
These steps were tested on CentOS 7.4 and RedHat 7.4 systems.
I use vim, but feel free to install and use whatever editor you like
I use PostgreSQL 9.6.3 as my database, but you can also MySQL
The whitespace used in the YAML .conf files is different in Bacula version 9 as it
is in version 5.5 (the version included in many package managers at the time of this
writing), so be sure to adjust according to the version 9 standards if you copy and past
from older versions.
Multiple Bacula servers can be used, but I only use one in this architecture
It’s best to monitor system for at least a month before putting it into
production so that you can tweak file sets and test the monthly backup. It’s also
difficult to reduce the disk space that your backups take if the first file sets are
restrictive enough for you needs.
FQDN:
If your client doesn’t already have a Fully Qualified Domain Name (FQDN),
assign it one.
I use server.example.local in this tutorial.
Create directories:
mkdir -p /bacula/backup
mkdir -p /bacula/restore
chown -R bacula:bacula /bacula
chmod -R 700 /bacula
mkdir /opt/bacula/bin -p
mkdir /opt/bacula/etc
mkdir /opt/bacula/work
INSTALL BACULA
wget -O-
https://sourceforge.net/projects/bacula/files/bacula/9.0.3/bacula-
9.0.3.tar.gz/download | tar -xzvf - -C /tmp
CFLAGS="-g -Wall" \
./configure \
#--enable-bat \ #Only needed if you plan on using the BAT GUI (which can be very
difficult to get to work)
--sbindir=/opt/bacula/bin \
--sysconfdir=/opt/bacula/etc \
--with-pid-dir=/opt/bacula/work \
--with-subsys-dir=/opt/bacula/work \
--enable-smartalloc \
--with-postgresql=/usr/pgsql-9.6 \
--with-python=/usr/bin/python \
--with-working-dir=/opt/bacula/work \
--with-dump-email=$USER
OPTIONAL CONFIGURATION
I often traverse the Bacula directories and restart components during
configuration, so these variables/aliases save me a lot of time
Add environment variable to bash_profile:
vim ~/.bash_profile
#Custom Bacula variables:
BC=/opt/bacula
BCE=/opt/bacula/etc
BCB=/opt/bacula/bin
source ~/.bash_profile
bac-status
bac-restart
CONFIGURE PostgreSQL
Reference: Configuring PostGreSQL - Bacula Documentation
See below section for PostgreSQL troubleshooting.
Scroll to the bottom section and create a new entry for bacula user,db and md5
authentication. Also create an entry for your Bacula Server’s IP. For example:
# TYPE DATABASE USER ADDRESS
METHOD
local bacula bacula
md5
host bacula bacula 192.168.0.20/24
trust
Start PostgreSQL:
touch /var/lib/pgsql/9.6/data/logfile
postgres -D /var/lib/pgsql/9.6/data/pg_xlog/ >logfile 2>&1 &
A PID should return, indicating that the PostgreSQL process is running.
See the PostgreSQL entries in the TROUBLESHOOTING section at the
bottom of this tutorial if you run into issues.
Restart PostgreSQL:
It seems unnecessary to do this right after starting it, but I found that the
changes I made to the postgres config files did not stick until after I restarted
it. vim /var/lib/pgsql/9.6/data/pg_hba.conf #
CONFIGURE bacula-dir.conf
Add DirAddress to restrict what IP addresses Bacula will use for IP binding.
Make sure backups are compressed
Specify FileSet
See full bacula-dir.conf sample file [To-Do: Specify where they can find this
file]. Make sure ‘Catalog{}’ section is updated with postgres password (detailed in
PostgreSQL section above)
Consider making Job names more intuitive
Consider updating the email field with an external email
The default bacula-dir.conf has a lot of comments. Mine are preceeded by
the: #!! sign.
bacula-dir.conf is a big file, so only the sections that I changed are included
below. For a full example of the file, see # TO -DO: include reference.
vim /opt/bacula/etc/bacula-dir.conf
Job {
Name = "RestoreLocalFiles"
Type = Restore
Client=server.example.local-fd
Storage = File1
# The FileSet and Pool directives are not used by Restore Jobs
# but must not be removed
FileSet="BaculaConfigs-Home-Root"
Pool = LocalFiles
Messages = Standard
Where = /bacula/restore #!! Previously: /tmp/bacula-restore
}
FileSet {
Name = "BaculaConfigs-Home-Root"
Include {
Options {
signature = MD5
compression = GZIP #!! Added this option to save disk space.
}
File = /opt/bacula/
File = /home
File = /root
}
Exclude {
File = /bacula ## No need to back up your backup files to the same Bacula server
twice.
}
}
Storage {
Name = File
Address = server.example.local
SDPort = 9103
Password = "0NbfHREkVIjoIDaIszRBZFBtaMBWbHCy+e0by3HKWOOZ" ## Paste
password from Autochanger {} section below
Device = HP-Drives
Media Type = File
}
##! Optional: tweak the "Default pool definition" and "File Pool definition" sections to you needs:
# Default pool definition
Pool {
Name = Default
Pool Type = Backup
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 = 5 # Limit number of Volumes in Pool
}
#
CONFIGURE bacula-sd.conf:
vim /opt/bacula/etc/bacula-sd.conf
Only sections that need to be changed are included here. Refer to (TO-DO - list)
for a fully copy of bacula-sd.conf
See #!! comments for instructions on what to change:
Storage { # definition of myself
Name = server.example-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/opt/bacula/work"
Pid Directory = "/opt/bacula/work"
Plugin Directory = "/usr/lib64"
Maximum Concurrent Jobs = 20
SDAddress = server.example.local #!! Add SDAddress line with your FQDN
}
#!! Add Device {} section below
Device {
Name = HP-Drives
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;
}
#!! Change `Archive Device` section for each changer from /tmp to /bacula/backup. This sets
where Volumes are saved.
Device {
Name = FileChgr1-Dev1
Media Type = File1
Archive Device = /bacula/backup #!! previously /tmp
Job {
Name = "Client1"
JobDefs = "DefaultJob"
Client = client1-example.local-fd
Pool = Client1
FileSet="Client1"
}
#
Possible Error 1:
bacula-test1-dir JobId 0: Fatal error: Unable to authenticate
with File daemon at "192.168.0.20:9102".
Possible causes:
* Passwords or names not the same or
* Maximum Concurrent Jobs exceeded on the FD or
* FD networking messed up (restart daemon)
Debugging Error 1:
Make sure name and password are the same for client in bacula-
dir.conf and clients.conf. Do not confuse this password with the
generic bacula-dir.conf` password - that one should never go on a client’s config
file.
Make sure the Director’s Name field indeed points to the Bacula Server and
not the local Client that you are installing. *Similarly, check that Director’s Name field
has ‘dir’ suffix (e.g., client.example.local-dir)
Make sure to restart the bacula-dir, bacula-fd, and bacula-sd services on
the server and the bacula-fd service on client after making config changes.
#
Symptom:
messages shows Backup--with errors
INSTALL BACULUM
See Bacula’s Baculum Documentation and make sure your system meets the
General Requirements.
They should’ve been installed when setting up the environment
Restart Postgres
systemctl restart postgresql-9.6.service
INSTALL TIGERVNC
For reference, see Digital Ocean’s How to Install and Configure VNC
Remote Access for the Gnome Desktop on CentOS7
yum install -y tigervnc-server *Installs version 1.3.1-9el7 on CentOS as of
08/16/2017
Configure TigerVNC
Make copies of generic VNC service unti file with the VNC subport:
cp /lib/systemd/system/[email protected]
/etc/systemd/system/vncserver@:4.service
cp /lib/systemd/system/[email protected]
/etc/systemd/system/vncserver@:5.service
vim /etc/systemd/system/vncserver@:4.service
Replace with `bacula`
Add -geometry 1280x1024”
vim /etc/systemd/system/vncserver@:5.service
Replace with `bacula`
Add -geometry 1280x1024”
Reload:
systemctl daemon-reload
Configure firewall:
Verify firewall is running:
firewall-cmd --state
Reload services:
systemctl daemon-reload
systemctl restart vncserver@:4.service
systemctl restart vncserver@:5.service
Enter the VNC password for the user you created to connect to the
5904 port
Note: This is not necessarily the same password as the Centos user’s password