5

Install and Use Bacula Backup on Rocky Linux 8|AlmaLinux 8

 2 years ago
source link: https://computingforgeeks.com/install-and-use-bacula-backup-on-rocky-almalinux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install and Use Bacula Backup on Rocky Linux 8|AlmaLinux 8

Bacula can be defined as a set of programs used to manage backup, restoration, and verification of data over a network. This open-source tool allows one to create backups and restore their data saved on media such as disks and backup tapes.

Bacula can not only run on a single computer but also on hundreds of connected devices. The Bacula server contains the following components:

  • Bacula Director: This is the centre of policy-based configurations for the backup and storage operations performed by the Storage and File daemons. It also schedules data backups and recoveries.
  • Storage Daemon: This deamon reads and writes data to physical backup media/volume.
  • Catalog: This is the service that maintains the database of files backed up. The database maybe PostgreSQL or MySQL.
  • Bacula File daemon: This is installed on individual clients. It is used to transfer the data of the client to be stored. This daemon basically knows the storage location and the type of data to be backed up.
  • Bacula Console: this is a Bacula command line where you can take backups and interact with the director.

The below diagram is an illustration of the Bacula Architecture.

The cool features related to Bacula are:

  • Has client support for many platforms that include Linux, Windows, Mac, and Unix systems.
  • Supports automated backup, restore, as well as archive operations
  • Centralized, web-based management of infrastructure
  • A distributed, scalable architecture that supports 1000s clients and PBs of data
  • Easy to install with little configurations to make.
  • Data reduction with compression and deduplication
  • Offers plugins for Oracle, MySQL, PostgreSQL, SAP
  • Support for storage devices like disk, VTL, tape, portable media
  • Offers LAN-free backup, SAN support, NDMP, bare metal restore

This guide demonstrates how to install and use Bacula Backup on Rocky Linux 8|AlmaLinux 8.

Step 1 – Prepare your server

Begin by updating all the packages on your server to the latest available versions.

sudo yum update

Disable SELinux as below.

sudo setenforce 0
sudo sudo sed -i "s/enforcing/disabled/g" /etc/sysconfig/selinux

It is recommended that you reboot the server after an upgrade for the changes made to the Kernel to apply.

sudo reboot

Step 2 – Install MariaDB on Rocky Linux 8|AlmaLinux 8

In this guide, we will use MariaDB as the database for Bacula. Install MariaDB on your system using the below command:

sudo yum install mariadb-server -y

Once installed, start and enable MariaDB.

sudo systemctl enable --now mariadb

Login to MariaDB using the root user.

sudo mysql -u root

Create a database for Bacula.

create database bacula; 
grant all privileges on bacula.* to bacula@'%' identified by 'Passw0rd';
flush privileges;
exit

Step 3 – Install Bacula on Rocky Linux 8|AlmaLinux 8

Bacula is available in the default Rocky Linux 8|AlmaLinux 8 package repositories. This makes it so easy to install it.

The below command can be used to install the Bacula components.

sudo dnf -y install bacula-director bacula-storage bacula-console bacula-client

Dependency tree:

Dependencies resolved.
================================================================================
 Package               Architecture Version               Repository       Size
================================================================================
Installing:
 bacula-client         x86_64       9.0.6-6.el8.1         appstream       152 k
 bacula-console        x86_64       9.0.6-6.el8.1         appstream        53 k
 bacula-director       x86_64       9.0.6-6.el8.1         appstream       408 k
 bacula-storage        x86_64       9.0.6-6.el8.1         appstream       192 k
Installing dependencies:
 bacula-common         x86_64       9.0.6-6.el8.1         appstream        35 k
 bacula-libs           x86_64       9.0.6-6.el8.1         appstream       500 k
 bacula-libs-sql       x86_64       9.0.6-6.el8.1         appstream       120 k
 libpq                 x86_64       13.3-1.el8_4          appstream       196 k
 mt-st                 x86_64       1.1-24.el8            appstream        52 k
 mtx                   x86_64       1.3.12-17.el8         appstream       142 k

Step 4 – Configure Bacula on Rocky Linux 8|AlmaLinux 8

Once all the components have been installed, proceed to the configuration. Here we will configure the Bacula database. Since we are using MariaDB as the database, we will make the below changes to Bacula.

sudo alternatives --config libbaccats.so

Proceed and switch the database support to MySQL as shown.

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

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

Enter to keep the current selection[+], or type selection number: 1

Create Bacula database tables.

sudo /usr/libexec/bacula/make_mysql_tables -u root

Create backup and restoring directories.

Bacula needs a directory for backup and restoring files. Create a new directory for Bacula as below.

sudo mkdir -p /bacula/backup /bacula/restore

Set the right permissions for the location.

sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula

The Bacula director config file can be opened for editing as below.

sudo vim /etc/bacula/bacula-dir.conf

Here, you need to make several configurations for the Bacula Director such as:

1. Set the listen Address

In the file, add the listen address 127.0.0.1 for the Director.

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 = 20
  Password = "@@DIR_PASSWORD@@"         # Console password
  Messages = Daemon
DirAddress = 127.0.0.1}

Proceed and configure the backup and restore local jobs

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

Still, in the file configure the Bacula director file set. Find the FileSet section and make the below changes.

FileSet {
Name = "Full Set"
Include {
    Options {
    signature = MD5
    compression = GZIP
    }
#
#  By default this is defined to point to the Bacula binary
#    directory to give a reasonable FileSet to backup to
#    disk storage during initial testing.
#
    File =/
}
Exclude {
    File = /var/lib/bacula
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
 File = /bacula}
}

3. Configure catalog connection

This bears connection information to your database in the bacula director config.

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

Save the file and check if the configuration is okay.

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

if no error is encountered, proceed to the Storage Daemon configuration.

Step 5 – Configure the Bacula Storage Daemon

Open the Bacula Storage file for editing:

sudo vim /etc/bacula/bacula-sd.conf

Configure the storage device under Devices and configure File1

# Define a Virtual autochanger
#
Autochanger {
....
Device {
  Name = FileChgr1-Dev2
  Media Type = File1
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 if the configuration file is okay.

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

Save the file, start and enable the Bacula services.

sudo systemctl enable --now bacula-dir.service bacula-fd.service bacula-sd.service

Check the status of the services:

systemctl status bacula-dir.service bacula-fd.service bacula-sd.service

Output:

At this point, the Bacula Director should be listening on port 9101.

$ sudo ss -plunt|grep 9101
tcp   LISTEN 0      50          127.0.0.1:9101       0.0.0.0:*    users:(("bacula-dir",pid=38394,fd=9)) 

Step 6 – Connect to the Bacula Console

Now connect to the Bacula director using the command:

sudo bconsole

Sample output:

Run a job.

*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
     1: BackupLocalFiles
     2: RestoreLocalFiles
     3: BackupCatalog
     4: RestoreFiles
Select Job resource (1-4): 1

Proceed as below to run a backup/restore job as configured.

Run Backup job
JobName:  BackupLocalFiles
Level:    Incremental
Client:   bacula-fd
FileSet:  Full Set
Pool:     File (From Job resource)
Storage:  File1 (From Job resource)
When:     2022-02-24 07:53:21
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=1
You have messages.

Show the status of the job.

*status client
Automatically selected Client: bacula-fd
Running Jobs:
Director connected at: 24-Feb-22 07:56
No Jobs running.
====

Terminated Jobs:
 JobId  Level      Files    Bytes   Status   Finished        Name 
===================================================================
     1  Full     140,389    5.424 G  OK       24-Feb-22 07:55 BackupLocalFiles
====
*

There are more commands that can be used in the console such as:

## reload console
* reload

## show filesets
* show filesets

## show dir status
* status dir

## show client status
* status client

## show storage
* status storage

## show messages (show only one time per job)
* message

## show job per ID and wait to be finished
* wait jobid=1

## restore all > all files are market to restore
 * restore all

## restore > manually mark/unmark files to restore
* restore

## if a restore fails you can re-try
* rerun jobid=1

Step 7 – Configure Bacula Remote Client

The Bacula remote client needs the Bacula File Daemon installed. This can be installed from the default package managers:

##On Debian/Ubuntu
sudo apt install bacula-client

##On RHEL/CentOS/Rocky Linux/Alma Linux
sudo yum install bacula-client

On Rhel-based systems, disable SELinux and allow port 9102 through the firewall.

sudo setenforce 0
sudo sudo sed -i "s/enforcing/disabled/g" /etc/sysconfig/selinux
sudo firewall-cmd --permanent --zone=public --add-port=9102/tcp
sudo firewall-cmd --reload

The client can also be installed on Windows systems. Once installed, proceed with the configuration below.

sudo vim /etc/bacula/bacula-fd.conf

Add the below lines to the file. Remember to set the Bacula director password, FD name, and IP.

Director {
  Name = bacula-dir ##Enter the name of the server’s Bacula Director here
  Password = "5sXAywtZfiNXNfl1M8poFdt9oU_GtHBSf" ## set the password to be used by the director to access the FD and copy it
}
...
FileDaemon {                          # this is me
Name = debian-fd  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/lib/bacula
  Pid Directory = /run/bacula
  Maximum Concurrent Jobs = 20
  Plugin Directory = /usr/lib/bacula
FDAddress = 192.168.205.4}

Check the file and restart the service

sudo bacula-fd -tc /etc/bacula/bacula-fd.conf
sudo systemctl restart bacula-fd.service

On the Bacula server, you need to add the client as below.

$ sudo vim /etc/bacula/bacula-dir.conf
.....
Client {
  Name = debian-fd  ##The file daemon name of the client
  Address = 192.168.205.4
  FDPort = 9102
  Catalog = MyCatalog
  Password = "5sXAywtZfiNXNfl1M8poFdt9oU_GtHBSf" # Paste here the value of the “Password” parameter in the “Director” section on the client
  File Retention = 1 year
  Job Retention = 1 year
  AutoPrune = yes
}

You can also create a job catalog for the remote client with directories /bacula/backup /bacula/restore created with the right permissions.

FileSet {
Name = "RemoteFS"
Include {
Options {
signature = MD5
}
File = /bacula/backup
}
}

Pool {
Name = RemotePool
Pool Type = Backup
Label Format = "RM-" # New label for separating files in the backup storage from local backups
}

Job {
  Name = "BackupRemoteFiles"
  Client=debian-fd
JobDefs = "DefaultJob"
Enabled = yes
FileSet = "RemoteFS" # The name of recently added “FileSet’ section
}
Job {
Name = "RemoteRestore"
Type = Restore
Client= "debian-fd"
FileSet="Full Set"
Storage = File1
Pool = "RemotePool"
Messages = Standard
Where = /bacula/restore # Path to the folder that we created on the client for data restore
Bootstrap = "/var/lib/bacula/RemoteBackup.bsr"
}

Save the file, restart the Bacula director.

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf
sudo systemctl restart bacula-dir.service

Create the backup folder on the remote system.

sudo mkdir -p /bacula/backup /bacula/restore
sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula

View the added client on the Bacula console

sudo bconsole
*status client
The defined Client resources are:
     1: bacula-fd
     2: debian-fd
Select Client (File daemon) resource (1-2): 2

Sample Output:

Conclusion.

That marks the end of this guide on how to install and use Bacula Backup on Rocky Linux 8|AlmaLinux 8. I hope this guide was important to you.

See more:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK