Installing Bacula + PostgreSQL on Centos 7

Bacula – cross-platform client-server software that allows you to manage backup, restore, and validation of data over the network for computers and operating systems of various types.

Add the Bacula repository. To do this, go to link, we fill in the from, we get access to the repository by email

Create a file with content:

$ sudo cat > /etc/yum.repos.d/bacula.repo
[bacula]
name=bacula repo
baseurl=https://bacula.org/packages/%код из письма%/rpms/9.4.4/el7/$basearch/
gpgcheck=0
enabled=1

Next, we need to disable SELinux, since Judging by developer’s answer in the release version today 9.4.4 they have not finished the connection between Bacula and SELinux yet

$ sudo setenforce 0
$ sudo nano /etc/selinux/config
...
SELINUX=disabled
...

Opening ports

$ sudo firewall-cmd --permanent --zone=public --add-port=9101-9103/tcp
$ sudo firewall-cmd --reload

Installing and Configuring PostgreSQL 10

Add PostgreSQL 10 repository

$ sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Install PostgreSQL 10, initialize the database server

$ sudo yum install postgresql10-server postgresql10-devel
$ sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ... OK

We start the service and add it to startup

$ sudo systemctl start postgresql-10
$ sudo systemctl enable postgresql-10

Create PostgreSQL user “bacula” and set the password “bacula”

$ sudo su - postgres
-bash-4.2$ createuser bacula
-bash-4.2$ psql
postgres=# ALTER USER bacula PASSWORD 'bacula';
postgres=# ALTER USER bacula LOGIN SUPERUSER CREATEDB CREATEROLE;
ALTER ROLE
postgres=# q
-bash-4.2$ exit

Configuring PostgreSQL Let’s comment out the listen_addresses line

$ sudo nano /var/lib/pgsql/10/data/postgresql.conf
listen_addresses="localhost"

Configuring connections to the database

$ sudo nano /var/lib/pgsql/10/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     peer
local   bacula          bacula                                  md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

Restarting PostgreSQL

$ sudo systemctl restart postgresql-10

Installing Bacula 9.4.4

Install Bacula

$ sudo yum install bacula-postgresql

We execute scripts for correct work of Bacula with PostgreSQL

$ cd /opt/bacula/scripts
$ sudo -u bacula ./create_postgresql_database
$ sudo -u bacula ./make_postgresql_tables
$ sudo -u bacula ./grant_postgresql_privileges

We make symlinks for ease of management, start the service and see the status

$ sudo ln -s /opt/bacula/bin/* /usr/bin
$ sudo bacula start
$ sudo bacula status

Create directories for backups / restores (you can mount NFS storage to them)

$ sudo mkdir -p /bacula/{backup,restore}
$ sudo chown -R apache:bacula /bacula
$ sudo chmod -R 777 /bacula

Create directories for logs

$ sudo mkdir /opt/bacula/log/
$ sudo chown -R bacula:bacula /opt/bacula/log/

Now you need to edit the Bacula configs, register our password

$ sudo nano /opt/bacula/etc/bacula-dir.conf

Configuring the Director resource

Find the Director resource and configure it to listen to an ip address. To do this, add the DirAddress line to the section.

Director {
...
  Password = "bacula"
  DirAddress = 192.168.1.25
}

Configuring local tasks

Bacula tasks (job) back up and restore data. Job resources provide detailed information about a specific job: client name, files to backup or restore (FileSet), and more. Find a Job resource named BackupClient1. Replace the value in the Name line with BackupLocalFiles.

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

Then find a Job resource named RestoreFiles. In the Name line, specify the name RestoreLocalFiles, and in the Where line – the / bacula / restore directory.

Job {
  Name = "RestoreLocalFiles"
...
  Where = /bacula/restore
}

Files for backup

FileSet defines the list of files and directories to include or exclude from the backup. Look for the FileSet resource named Full Set (under the comment # List of files to be backed up). Here you need to make the following changes:

  • Add gzip compression.
  • In the Include section, replace / usr / sbin on the File line with /.
  • At the end of the Exclude section, add the line File = / bacula.
# List of files to be backed up
FileSet {
  Name = "Full Set"
  Include {
    Options {
      signature = MD5
      compression = GZIP
    }
...
  Exclude {
  ...
    File = /bacula
  }
}

Directory setup

The Catalog resource defines the database the Director will connect to. Find the Catalog resource called MyCatalog (under the Generic catalog service comment). Update the dbpassword value and specify the password of the MySQL / PostgeSQL user bacula. You also need to add the address, otherwise when checking (sudo bacula-dir -tc /opt/bacula/etc/bacula-dir.conf) there is no database connection

# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; DB Address = "localhost"; dbuser = "bacula"; dbpassword = "bacula"
}

Pool setup

The Pool resource defines the set of storage locations used by Bacula to write backups. In this case, files are used as storage volumes. Update the labels so that local backups are correctly labeled.

# File Pool definition
Pool {
  ...
  Label Format = "Local-"               # Auto label
}

Save and close the file. The configuration of the Bacula Director component is complete.

Checking the settings

$ sudo bacula-dir -tc /opt/bacula/etc/bacula-dir.conf

Configuring the Storage Daemon

The Storage Daemon needs to be configured so that Bacula knows where to store files.

Open the SD configuration file.

$ sudo nano /opt/bacula/etc/bacula-sd.conf
Storage {                             # definition of myself
  ...
  SDAddress = 192.168.1.25
}

Setting up a storage device

Autochanger {
  Name = FileChgr1
  Device = FileChgr1-Dev1, FileChgr1-Dev2
  Changer Command = ""
  Changer Device = /dev/null
}

Device {
  Name = FileChgr1-Dev1
  Media Type = File1
  Archive Device = /bacula/backup
  ...
}

Device {
  Name = FileChgr1-Dev2
  Media Type = File1
  Archive Device = /bacula/backup
  ...
}

Checking the settings

$ sudo bacula-sd -tc /opt/bacula/etc/bacula-sd.conf

In all files, you need to change the password to our “bacula

Sidebar