Bacula Web Centos 7 - Installation Guide

The flexibility and richness of Bacula backup method make it the best backup solution for many situations. Here is how to install a Bacula Web Centos 7 server.

Learn More

An overview of the Bacula components

  • Catalog – these are maintenance services for backed up database files. The database is stored in SQL databases like PostgreSQL and MySQL.
  • Bacula Director (DIR) – This software handles backup and restore processes done by file and storage daemons.
  • Storage daemons (SD) – this software is responsible for the read and write function on storage devices used in backup processes.
  • Bacula Console – this is a command line interface used for interactions between the backup administrator and the control, and DIR.
Bacula Web Centos 7

How to install Bacula and MySQL

In this tutorial, you can use MariaDB as a drop-in replacement for MySQL. To install MariaDB and Bacula using Yum: sudo yum install -y bacula-director bacula-storage bacula-console bacula-client mariadb-server.

Once the installation is complete, you need to start MySQL through the following command: sudo systemctl start mariadb.

Next, you need to create a Bacula database user and tables using these scripts:

  • /usr/libexec/bacula/grant_mysql_privileges
  • /usr/libexec/bacula/create_mysql_database -u root
  • /usr/libexec/bacula/make_mysql_tables -u bacula

Run a simple security script to get rid of dangerous defaults and lock down access to your database system. To start the interactive script, run: sudo mysql_secure_installation

Because your MySQL is new, you can leave the root password prompt blank. Follow through the rest of the prompt to accept default values.

Set the password for the user database by entering the MySQL console as the root user: mysql -u root –p and enter the root password you set when prompted. Set the password or the database user: UPDATE mysql.user SET Password=PASSWORD('bacula_db_password') WHERE User='bacula'; FLUSH PRIVILEGES; replacing the ‘Baculadbpassoword’ with a strong password.

Exit the MySQL prompt and enable MariaDB to boot using command: sudo systemctl enable mariadb.

Setting Bacula to use the MySQL library

Set Bacula to use the MySQL Library. You can do this by running command: sudo alternatives --config libbaccats.so

On the prompt:

Output

There are 3 programs which provide 'libbaccats.so'.

SelectionCommand
1/usr/lib64/libbaccats-mysql.so
2/usr/lib64/libbaccats-sqlite3.so
*+ 3/usr/lib64/libbaccats-postgresql.so

Enter selection 1, which is MySQL to install the Bacula server/client components.

Creating backup and restoring directories

For Bacula to work on Centos 7, it needs a backup directory for backup archives and a restore directory for storing restored files. To create a new directory: sudo mkdir -p /bacula/backup /bacula/restore Change the file permissions to ensure only Bacula can access these location. To do this:

sudo chown -R bacula:bacula /bacula

sudo chmod -R 700 /bacula

Configuring Bacula Director

Access the configurations files in the /etc/bacula directory.

Open DIR configurations file in a text editor such as sudo vi /etc/bacula/bacula-dir.conf

Locate the DIR resource and configure to listen to local host 127.0.0.1 by adding the DirAddress line:

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
}

Configuring local jobs

Find the job resource named ‘NackupClient1’ and change the name to ‘BackupLocalFiles.

Job {
Name = "BackupLocalFiles"
JobDefs = "DefaultJob"
}

Change ‘RestoreFiles’ to ‘RestoreLocalFiles’ and the value of ‘where’ to /bacula/restore

Job {
Name = "RestoreLocalFiles"
Type = Restore
Client=BackupServer-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula/restore
}

Configuring file set

FileSet {
Name = "Full Set"
Include {
    Options {
    signature = MD5
    compression = GZIP
    }
File = /
}
Exclude {
    File = /var/lib/bacula
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
    File = /bacula
}
}

Configure storage daemon connection

Storage {
Name = File
# Do not use "localhost" here
Address = backup_server_private_FQDN                # N.B. Use a fully qualified name here
SDPort = 9103
Password = "@@SD_PASSWORD@@"
Device = FileStorage
Media Type = File
}

Configure catalog connection

# Generic catalog service

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 = "bacula_db_password"
}

Configure pool

# File Pool definition

Pool {
Name = File
Pool Type = Backup
Label Format = Local-
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
}

Check DIR configuration

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf – if it shows no error messages, you can move to configuring the storage daemon.

Configure Storage Daemon

Open SD configuration in a text editor: sudo vi /etc/bacula/bacula-sd.conf

Configure the storage resource:

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 = backup_server_private_FQDN
}

Configure storage device

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;
}

Verify storage daemon configuration: sudo bacula-sd -tc /etc/bacula/bacula-sd.conf

This completes the Bacula configuration. You can restart the Bacula server components.

Setting Bacula Component Passwords

DIR password command:

DIR_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@DIR_PASSWORD@@/${DIR_PASSWORD}/" /etc/bacula/bacula-dir.conf
sudo sed -i "s/@@DIR_PASSWORD@@/${DIR_PASSWORD}/" /etc/bacula/bconsole.conf

Storage daemon password command:

SD_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@SD_PASSWORD@@/${SD_PASSWORD}/" /etc/bacula/bacula-sd.conf
sudo sed -i "s/@@SD_PASSWORD@@/${SD_PASSWORD}/" /etc/bacula/bacula-dir.conf

Local file daemon password command:

FD_PASSWORD=`date +%s | sha256sum | base64 | head -c 33`
sudo sed -i "s/@@FD_PASSWORD@@/${FD_PASSWORD}/" /etc/bacula/bacula-dir.conf
sudo sed -i "s/@@FD_PASSWORD@@/${FD_PASSWORD}/" /etc/bacula/bacula-fd.conf

You can now start your Bacula components and test the backup job.

Bacula Support