Install Bacula Backup Server on CentOS or AlmaLinux 8
If you’ve ever had to point a backup server at a bunch of Linux boxes and then watch the logs explode, you’ll appreciate how much time you can save by getting Bacula up and running quickly and correctly. Below is a no‑frills, step‑by‑step guide that covers everything from the initial package install to making sure your clients can talk to the director.
5 Prerequisites
- A fresh CentOS 8 or AlmaLinux 8 system with a non‑root user who has sudo privileges.
- Internet connectivity for pulling packages from EPEL and Remi repositories.
- Basic familiarity with the command line; you’ll be typing commands, not dragging icons.
I’ve seen people stumble on this step when they skip adding the correct repos—Bacula’s official repo isn’t bundled with RHEL‑derived distros, so you need to grab it yourself. Once the repos are in place, the rest is mostly automated.
Enable Required Repositories
sudo dnf install -y epel-release sudo dnf config-manager --set-enabled powertools
Bacula ships from the EPEL and PowerTools (or crb on AlmaLinux) repositories. Without them, the bacula-director, bacula-sd, and bacula-console packages won’t resolve.
Install Bacula Packages
sudo dnf install -y bacula-dir bacula-sd bacula-client bacula-console
The three core components—Director, Storage Daemon, and Console—install together with their dependencies. The bacula-client package is optional unless you plan to run the client on the same machine.
Configure the Database
Bacula can use MySQL/MariaDB or PostgreSQL; I prefer PostgreSQL because it ships in AlmaLinux’s base repo. If you already have a DB, skip ahead to “Create Bacula User” below.
sudo dnf install -y postgresql-server sudo postgresql-setup --initdb sudo systemctl enable --now postgresql
Once the service is running, create the bacula database and user:
sudo -i -u postgres psql CREATE DATABASE bacula; CREATE USER bacula WITH ENCRYPTED PASSWORD 'supersecret'; GRANT ALL PRIVILEGES ON DATABASE bacula TO bacula; \q
A real‑world scenario: I’ve seen admins forget to grant CONNECT on the database, which causes the director to log “permission denied” every time it starts. Double‑check that.
Create Bacula Configuration Files
The default config files are minimal but useful as a starting point. Copy them into place and tweak:
sudo cp /usr/share/doc/bacula//bacula-dir.conf.example /etc/bacula/bacula-dir.conf sudo cp /usr/share/doc/bacula//bacula-sd.conf.example /etc/bacula/bacula-sd.conf
Edit bacula-dir.conf
Open /etc/bacula/bacula-dir.conf and make sure:
Director {
Name = bacula-dir
Password = "mydirpass"
QueryFile = "/etc/bacula/bacula-dir-query.sql"
DBParameters = "dbname=bacula user=bacula password=supersecret hostaddr=127.0.0.1"
}
The DBParameters line tells the director how to talk to PostgreSQL. A typo here will bring the whole system down.
Edit bacula-sd.conf
Storage {
Name = bacula-storage
Address = "$(hostname -f)"
SDPort = 9103
Password = "myspass"
Device = FileStorage
Media Type = File
}
The storage daemon must know the password and port; otherwise clients can’t hand over files.
Generate SQL Schema
Bacula ships with an SQLite schema file. To convert to PostgreSQL, run:
sudo -u bacula /usr/bin/bacula-sd --generate-sql
This creates /etc/bacula/bacula-dir.sql. Import it into your DB:
psql -U bacula -d bacula -f /etc/bacula/bacula-dir.sql
If you get a “duplicate key” error, the schema was already imported. Just ignore it.
Start and Enable Services
sudo systemctl enable --now bacula-director bacula-sd bacula-console
Check status:
systemctl status bacula-director bacula-sd | grep Active
You should see “active (running)” for both.
Open Firewall Ports
If you’re running firewalld, expose the director and storage ports:
sudo firewall-cmd --permanent --add-port=9102/tcp sudo firewall-cmd --permanent --add-port=9103/tcp sudo firewall-cmd --reload
Without this, clients will hit a connection timeout.
Configure Clients
On each client machine:
sudo dnf install -y bacula-client sudo vi /etc/bacula/bacula-fd.conf
Add your director’s address and password:
Director {
Name = bacula-dir
Password = "mydirpass"
Address = "<director-ip>"
FDPort = 9102
}
FileDaemon {
Name = <client-hostname>
WorkingDirectory = /var/spool/bacula
Pid Directory = /var/run/bacula
}
Restart the file daemon:
sudo systemctl enable --now bacula-fd
Test a Simple Backup
From the director host, run the console:
sudo -u bacula bconsole
In bconsole, type:
run job=MyBackupJob level=Full
If you don’t have a job defined yet, create a minimal one in /etc/bacula/ with your client and storage references. A quick test will show whether the job completes or if there are connection errors.
That’s it—Bacula is now listening for clients, the director knows where to store files, and you can start building proper backup schedules. If you run into “Permission denied” or “Connection refused” messages, double‑check those passwords and firewall rules; they’re the usual suspects.