How to Set Up a Backup Server Using Bacula on Debian 12 Bookworm
Categories:
5 minute read
Data loss can be catastrophic — whether caused by hardware failure, accidental deletion, or malicious activity. For system administrators and power users managing critical data, having a reliable backup system is not optional. One of the most flexible and powerful open-source backup solutions is Bacula.
In this tutorial, we’ll walk through how to set up a backup server using Bacula on a Debian 12 (Bookworm) system. We’ll cover the installation of the necessary packages, configuration of the Director, Storage Daemon, and File Daemon, and finish with a working backup and restore setup.
What is Bacula?
Bacula is a set of programs that allow you to manage backup, recovery, and verification of data across a network. It is scalable, supports various storage types (disks, tapes, cloud), and separates roles into different daemons for better modular control:
- Director (Dir): The central component managing all backups.
- Storage Daemon (SD): Handles the storage and retrieval of backup data.
- File Daemon (FD): Installed on clients to be backed up; handles reading and restoring files.
- Catalog: Stores metadata about backups, typically using MySQL or PostgreSQL.
Prerequisites
Before we begin, ensure you have the following:
- A Debian 12 Bookworm server with root or sudo access.
- A static IP address configured (especially for remote client/server setups).
- Internet access to download packages.
- At least 2 GB of RAM and 10+ GB of disk space for testing (more for production).
Step 1: Update the System
Start by updating the system packages to the latest versions:
sudo apt update && sudo apt upgrade -y
Install essential tools:
sudo apt install -y vim wget curl net-tools
Step 2: Install the Bacula Packages
Debian 12 provides Bacula through the official repositories. For a full backup server, install the following:
sudo apt install -y bacula-director bacula-sd bacula-fd bacula-common-mysql mariadb-server
This installs:
- The Director to manage jobs.
- The Storage Daemon to store backups.
- The File Daemon to be backed up (this can be remote in multi-host setups).
- MariaDB, which we’ll use for the catalog database.
Step 3: Configure the Bacula Catalog Database
Start and secure MariaDB:
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation
Create a database and user for Bacula:
sudo mysql -u root -p
CREATE DATABASE bacula;
CREATE USER 'bacula'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
GRANT ALL PRIVILEGES ON bacula.* TO 'bacula'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Next, populate the database with Bacula’s schema:
cd /usr/lib/bacula
sudo ./create_bacula_database
sudo ./make_bacula_tables
sudo ./grant_bacula_privileges
Step 4: Configure the Bacula Director
The Bacula Director configuration is located at:
/etc/bacula/bacula-dir.conf
Make sure the Catalog
section uses the database details:
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "StrongPasswordHere"
}
Define a basic backup job. You can use the default Client
and JobDefs
, but here’s a simple custom example:
Job {
Name = "BackupLocalhost"
JobDefs = "DefaultJob"
Write Bootstrap = "/var/lib/bacula/BackupLocalhost.bsr"
}
Ensure the FileSet
includes relevant directories:
FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5
}
File = /etc
File = /home
File = /var/log
}
}
Also, check the Director
section in bacula-fd.conf
(File Daemon config) and bacula-sd.conf
(Storage Daemon config) matches the Director’s name and password.
Step 5: Configure the Storage Daemon
File: /etc/bacula/bacula-sd.conf
Ensure the storage is defined properly. Look for the Device
section:
Device {
Name = FileStorage
Media Type = File
Archive Device = /var/backups
LabelMedia = yes;
Random Access = yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = yes;
}
Create the backup directory and give ownership to the Bacula user:
sudo mkdir /var/backups
sudo chown bacula:bacula /var/backups
Step 6: Configure the File Daemon
File: /etc/bacula/bacula-fd.conf
Make sure the Director
section matches what’s defined in the Director configuration file:
Director {
Name = bacula-dir
Password = "secret-password-from-dir"
}
Step 7: Start and Enable Bacula Services
Enable and start all Bacula services:
sudo systemctl enable bacula-director
sudo systemctl enable bacula-sd
sudo systemctl enable bacula-fd
sudo systemctl start bacula-director
sudo systemctl start bacula-sd
sudo systemctl start bacula-fd
Check status:
sudo systemctl status bacula-director
Step 8: Using bconsole
bconsole
is the command-line console for Bacula.
Launch it:
sudo bconsole
Inside bconsole
, try listing clients:
*status director
*status client
*status storage
To run a manual backup job:
*run
Follow the prompts to choose the Job and other options.
To monitor job progress:
*status dir
Step 9: Test a Restore
Once a backup has completed, test the restoration process:
*restore
This launches a wizard-style interface:
- Choose the backup to restore from.
- Select the files or directories.
- Specify the restore location (default is
/tmp/bacula-restores
).
Make sure the restore works as expected.
Step 10: Automate Backup Jobs
Jobs in Bacula can be scheduled using the Schedule
resource.
Example:
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sun at 01:00
Run = Incremental mon-sat at 01:00
}
Apply it to your JobDefs
:
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = Default
Priority = 10
}
Step 11: Firewall Configuration (Optional)
If your Bacula services are communicating over a network (especially between client and server), allow the appropriate ports:
- Director to File Daemon: TCP 9102
- Director to Storage Daemon: TCP 9103
- bconsole to Director: TCP 9101
sudo ufw allow 9101/tcp
sudo ufw allow 9102/tcp
sudo ufw allow 9103/tcp
Final Thoughts
Setting up Bacula on Debian 12 Bookworm provides a robust foundation for managing data backups in a secure, centralized, and scalable manner. While it might seem complex at first, Bacula’s separation of roles gives you flexibility and control that many GUI-based backup tools lack.
You can expand this setup to include multiple clients, remote storage options, email notifications, and even cloud integration. If you’re managing critical infrastructure or sensitive data, a Bacula-based solution ensures you’re never caught without a safety net.
Useful Commands Recap
sudo systemctl status bacula-director
sudo systemctl status bacula-sd
sudo systemctl status bacula-fd
sudo bconsole
*status director
*run
*restore
References
- Official Bacula Documentation
- Debian Wiki: Bacula
- Man pages:
man bacula-dir
,man bacula-sd
,man bacula-fd
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.