11.12.2024

How to Configure Remote Backups using Bacula on CentOS 8

In this tutorial, we will install the Bacula client on a CentOS 8 server and use it to back up files. Backups will be stored on a remote server. For this purpose, we will use the Ubuntu machine where we installed and configured Bacula Director. You can use any other operating system for this: CentOS, RHEL, Debian, etc. Bacula configuration will be the same.

Installing and configuring the Bacula client

Install the client.

dnf install bacula-client

If your firewall is enabled, add a Bacula rule to it.

firewall-cmd --add-service=bacula-client --permanent
firewall-cmd --reload

Now open the Bacula client configuration file.

nano /etc/bacula/bacula-fd.conf

Specify the password for the Client and the name of the Bacula director from the /etc/bacula/bacula-dir.conf file on the server:

Director {
Name = bacula-dir
Password = "password"
}

You will also need to enter the client's name and the IP address that Bacula Director will use to access the client.

FileDaemon {
Name = CentOS-client-fd
...
FDAddress = 10.0.0.5
}

Save the file and enable Bacula client.

systemctl enable --now bacula-fd

To ensure the ability to restore files on this machine, create a folder and assign Bakula as its owner.

mkdir /var/bacula
chown bacula:bacula /var/bacula

Bacula Director configuration

You need to make some changes on the server machine to enable remote backup. First, enter the IP address that Bacula client will use to access this machine in the SDAddress parameter of the Storage section in the /etc/bacula/bacula-sd.conf file.

Storage {
...
SDAddress = 10.0.0.10
}

Do the same thing for the DirAddress in the /etc/bacula/bacula-dir.conf file.

Director {
...
DirAddress = 10.0.0.10
}

And in the Address parameter of the Storage section.

Storage {
...
Address = 10.0.0.10
}

And the last one is in the /etc/bacula/bconsole.conf file, enter the same IP in the address parameter.

Director {
...
address = 10.0.0.10
}

You need to add information about the client and its backup parameters to the /etc/bacula/bacula-dir.conf file. Name, Address and Password must be the same as we specified on the client in the /etc/bacula/bacula-fd.conf file.

Client {
Name = CentOS-client-fd
Address = 10.0.0.5
FDPort = 9102
Catalog = MyCatalog
Password = "password"
}

Add the backup path information to the File parameters in a new FileSet section with a unique name.

FileSet {
Name = CentOS-FS
Include {
Options {
signature = MD5
}
File = /path/to/be/backuped1
File = /path/to/be/backuped2
}
}

Then insert a new schedule with a new name and the required backup frequency.

Schedule {
Name = CentOS-Daily
Run = Full daily at 01:00
}

The new pool allows you to separate backup files from existing ones.

Pool {
Name = CentOS-Pool
Pool Type = Backup
Label Format = CentOS-
}

Finally, insert a Job section and enter the Name parameters from newly created Client, FileSet, Schedule, Pool sections in corresponding fields.

Job {
Client = CentOS-client-fd
Name = CentOS-Backup
JobDefs = DefaultJob
Enabled = yes
Level = Full
FileSet = CentOS-FS
Schedule = CentOS-Daily
Pool = CentOS-Pool
Storage = LocalSD
Write Bootstrap = "/var/lib/bacula/RemoteBackup.bsr"
}

You can insert another Job section to restore files.

Job {
Client = CentOS-client-fd
Name = CentOS-Restore
Messages = Standard
FileSet = CentOS-FS
Pool = CentOS-Pool
Storage = LocalSD
Type = Restore
Bootstrap = "/var/lib/bacula/RemoteBackup.bsr"
Where = /var/bacula # Path on the client to restore the backup
}

The backup task will now run according to the configured schedule.

Starting backup and restore

Tasks can be started manually. There is a management console for this purpose. It also provides information about scheduled tasks and many others. To enter it enter:

bconsole

Output:

Connecting to Director 10.0.0.10:9101
1000 OK: 103 Ubuntu-Server.local-dir Version: 9.4.2 (04 February 2019)
Enter a period to cancel a command.
*

You can see all the commands by typing help command. To run a Job enter run or to start a restore Job enter restore and follow the instructions.