How To

Install Bareos Backup on Ubuntu 24.04 / 22.04

Bareos (Backup Archiving Recovery Open Sourced) is a powerful open-source backup solution forked from the well-known Bacula project. It handles backup, restore, and verification of data across a network for Linux, Windows, and macOS clients. Bareos improves on Bacula with a cleaner codebase, active community development, a built-in web interface (Bareos WebUI), and better integration with modern storage backends.

Original content from computingforgeeks.com - post 8320

Bareos uses a client-server architecture with three main daemons: the Director (controls all backup operations), the Storage Daemon (writes data to storage media), and the File Daemon (runs on each client machine being backed up). The catalog database – PostgreSQL in modern versions – tracks every file that has been backed up.

This guide walks through a full Bareos installation on Ubuntu 24.04 and 22.04 using the official Bareos community repository. By the end, you will have a working Director, Storage Daemon, File Daemon, PostgreSQL catalog, a configured backup job, and the Bareos WebUI running behind Apache with HTTPS.

Prerequisites

Before starting, make sure you have the following in place:

  • Ubuntu 24.04 or 22.04 server with root or sudo access
  • Minimum 2 GB RAM and 2 CPU cores (more for large environments)
  • Sufficient disk space for backup storage (a separate partition or volume is recommended)
  • A fully qualified domain name or static IP address
  • Firewall access to ports 9101-9103 (Bareos daemons) and 443 (WebUI)

Step 1: Add the Bareos Community Repository

The Bareos packages in Ubuntu’s default repositories are outdated. The official Bareos community repository provides the latest stable builds – version 25.x at the time of writing. Start by downloading and running the official repository setup script.

For Ubuntu 24.04:

wget -qO /tmp/add_bareos_repositories.sh https://download.bareos.org/current/xUbuntu_24.04/add_bareos_repositories.sh
sudo bash /tmp/add_bareos_repositories.sh

For Ubuntu 22.04:

wget -qO /tmp/add_bareos_repositories.sh https://download.bareos.org/current/xUbuntu_22.04/add_bareos_repositories.sh
sudo bash /tmp/add_bareos_repositories.sh

The script creates the APT source file at /etc/apt/sources.list.d/bareos.sources and imports the Bareos GPG signing key. Update the package index after adding the repository:

sudo apt update

You should see the Bareos repository listed in the output with no GPG errors.

Step 2: Install PostgreSQL Database Server

Bareos uses PostgreSQL as its catalog database. The MySQL/MariaDB backend was removed in Bareos 21 – PostgreSQL is the only supported option. Install it from the default Ubuntu repositories:

sudo apt install -y postgresql postgresql-client

Verify that PostgreSQL is running:

sudo systemctl status postgresql

The service should show active (exited) – this is normal for PostgreSQL since the main process is managed by the cluster service. Ubuntu 24.04 ships PostgreSQL 16, while Ubuntu 22.04 ships PostgreSQL 14. Both versions work with Bareos.

Step 3: Install Bareos Packages

Install the core Bareos components: the Director, Storage Daemon, File Daemon, database tools, console, and web interface.

sudo apt install -y bareos bareos-database-postgresql bareos-bconsole bareos-webui

This meta-package pulls in everything needed for a single-server setup:

  • bareos-director – the central control daemon
  • bareos-storage – manages backup storage devices
  • bareos-filedaemon – the backup client agent (installed on this server too)
  • bareos-database-postgresql – PostgreSQL catalog integration
  • bareos-bconsole – command-line admin console
  • bareos-webui – the web-based management interface
  • bareos-common – shared libraries

Step 4: Initialize the Bareos Catalog Database

Bareos ships database scripts that create the PostgreSQL user, database, and schema. Run them in order as the postgres system user:

sudo -u postgres /usr/lib/bareos/scripts/create_bareos_database
sudo -u postgres /usr/lib/bareos/scripts/make_bareos_tables
sudo -u postgres /usr/lib/bareos/scripts/grant_bareos_privileges

Each command should complete without errors. These scripts create a PostgreSQL database called bareos with a bareos user, populate the catalog schema, and grant the necessary permissions.

Verify the database was created:

sudo -u postgres psql -l | grep bareos

You should see the bareos database listed with bareos as the owner:

 bareos    | bareos | UTF8     | C.UTF-8  | C.UTF-8  |

Step 5: Start and Enable Bareos Services

Start all three Bareos daemons and enable them to survive reboots:

sudo systemctl enable --now bareos-director
sudo systemctl enable --now bareos-storage
sudo systemctl enable --now bareos-filedaemon

Check that all services are running:

sudo systemctl status bareos-director bareos-storage bareos-filedaemon

All three daemons should show active (running). If the Director fails to start, the most common cause is a database connection issue – check /var/log/bareos/bareos.log for details.

Step 6: Understand the Bareos Configuration Structure

Bareos uses a resource-based configuration stored in /etc/bareos/. Unlike older Bacula-style monolithic config files, Bareos splits each resource type into its own file under subdirectories. The main configuration directories are:

  • /etc/bareos/bareos-dir.d/ – Director configuration (jobs, clients, schedules, pools, filesets)
  • /etc/bareos/bareos-sd.d/ – Storage Daemon configuration (devices, storage)
  • /etc/bareos/bareos-fd.d/ – File Daemon configuration (client-side settings)
  • /etc/bareos/bconsole.d/ – Console configuration
  • /etc/bareos/bareos-webui.d/ – WebUI Director connection settings

Each subdirectory contains further directories organized by resource type. For example, /etc/bareos/bareos-dir.d/job/ holds all job definitions, and /etc/bareos/bareos-dir.d/client/ holds client definitions.

Step 7: Configure the Director (bareos-dir)

The Director is the brain of Bareos. The default installation creates a working configuration that backs up the Bareos catalog and the local filesystem. Review the main Director resource:

sudo cat /etc/bareos/bareos-dir.d/director/bareos-dir.conf

The default Director configuration looks similar to this:

Director {
  Name = bareos-dir
  QueryFile = "/usr/lib/bareos/scripts/query.sql"
  Maximum Concurrent Jobs = 10
  Password = "RANDOM_PASSWORD_HERE"
  Messages = Daemon
  Auditing = yes
}

The password is auto-generated during installation. You generally do not need to change it unless you are connecting remote consoles.

Configure the Storage Resource

The Director needs to know where the Storage Daemon is. Check the storage resource:

sudo cat /etc/bareos/bareos-dir.d/storage/File.conf

The default configuration points to localhost, which is correct for a single-server setup:

Storage {
  Name = File
  Address = localhost
  Password = "RANDOM_PASSWORD_HERE"
  Device = FileStorage
  Media Type = File
}

If your backup storage is on a remote server, change the Address to that server’s hostname or IP.

Review the Default Client (File Daemon)

The Director ships with a default client resource for the local machine:

sudo cat /etc/bareos/bareos-dir.d/client/bareos-fd.conf

The default client resource connects to the local File Daemon:

Client {
  Name = bareos-fd
  Address = localhost
  Password = "RANDOM_PASSWORD_HERE"
}

Step 8: Configure a Backup FileSet

A FileSet defines which files and directories to include or exclude from a backup job. The default installation includes a basic SelfTest FileSet that only backs up the /usr/sbin directory. Create a more practical FileSet for backing up system directories.

Create a new FileSet configuration file:

sudo vi /etc/bareos/bareos-dir.d/fileset/LinuxAll.conf

Add the following configuration:

FileSet {
  Name = "LinuxAll"
  Description = "Back up all important Linux directories"
  Include {
    Options {
      Signature = MD5
      Compression = LZ4
    }
    File = /etc
    File = /home
    File = /var/log
    File = /var/spool
    File = /root
    File = /opt
    File = /srv
  }
  Exclude {
    File = /proc
    File = /sys
    File = /tmp
    File = /run
    File = /dev
    File = /var/cache
    File = /var/tmp
  }
}

This FileSet uses LZ4 compression (fast with reasonable compression ratio) and MD5 signatures for data integrity verification. Adjust the Include and Exclude lists based on what matters in your environment.

Step 9: Configure a Backup Schedule

Bareos ships with a default WeeklyCycle schedule, but creating a custom schedule gives you more control. Create a new schedule:

sudo vi /etc/bareos/bareos-dir.d/schedule/DailyBackup.conf

Add the following schedule definition:

Schedule {
  Name = "DailyBackup"
  Run = Level=Full 1st sun at 02:00
  Run = Level=Differential 2nd-5th sun at 02:00
  Run = Level=Incremental mon-sat at 02:00
}

This schedule runs a Full backup on the first Sunday of every month, Differential backups on the remaining Sundays, and Incremental backups Monday through Saturday – all at 2:00 AM. This is a solid balance between storage usage and restore speed for most environments.

Step 10: Create a Backup Job

Now tie everything together by creating a backup job. This job references the client, FileSet, schedule, and storage pool.

sudo vi /etc/bareos/bareos-dir.d/job/BackupLocalFiles.conf

Add the following job definition:

Job {
  Name = "BackupLocalFiles"
  JobDefs = "DefaultJob"
  Client = "bareos-fd"
  FileSet = "LinuxAll"
  Schedule = "DailyBackup"
  Storage = File
  Pool = Incremental
  Full Backup Pool = Full
  Differential Backup Pool = Differential
  Write Bootstrap = "/var/lib/bareos/%c.bsr"
  Priority = 10
}

The job inherits default settings from DefaultJob (defined in /etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf) and overrides the FileSet, schedule, and pool assignments. The bootstrap file written at /var/lib/bareos/%c.bsr is critical for disaster recovery – it contains enough information to restore the most recent backup without the catalog.

Step 11: Configure the Storage Daemon

The Storage Daemon manages the actual backup storage devices. The default configuration stores backups in /var/lib/bareos/storage/. Review the device configuration:

sudo cat /etc/bareos/bareos-sd.d/device/FileStorage.conf

The default device configuration stores backups as files on disk:

Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /var/lib/bareos/storage
  LabelMedia = yes
  Random Access = yes
  AutomaticMount = yes
  RemovableMedia = no
  AlwaysOpen = no
}

If you have a dedicated backup partition or volume, change Archive Device to point there. Make sure the bareos user owns the directory:

sudo mkdir -p /backup/bareos
sudo chown bareos:bareos /backup/bareos

Then update the Archive Device path in the configuration file to /backup/bareos.

Step 12: Configure the File Daemon

The File Daemon (client agent) runs on every machine you want to back up. On the Bareos server itself, it is already installed and configured. Review the configuration:

sudo cat /etc/bareos/bareos-fd.d/client/myself.conf

The default File Daemon configuration:

Client {
  Name = bareos-fd
  Maximum Concurrent Jobs = 20
}

The Director connection is configured in /etc/bareos/bareos-fd.d/director/bareos-dir.conf, which contains the password that must match the client resource on the Director side. The installation handles this automatically.

Step 13: Validate the Configuration

Before reloading the Director with the new configuration, test it for syntax errors:

sudo bareos-dir -t -c /etc/bareos/bareos-dir.d

If the configuration is valid, the command returns without any output. Any errors will be printed with the specific file and line number. Fix them before proceeding.

Also validate the Storage Daemon and File Daemon configurations:

sudo bareos-sd -t -c /etc/bareos/bareos-sd.d
sudo bareos-fd -t -c /etc/bareos/bareos-fd.d

Once all three pass validation, reload the Director to pick up the changes:

sudo systemctl reload bareos-director

Step 14: Run Your First Backup Job

Connect to the Bareos Director using the bconsole command-line tool:

sudo bconsole

You should see the bconsole prompt confirming a successful connection to the Director:

Connecting to Director localhost:9101
  Encryption: TLS_CHACHA20_POLY1305_SHA256 TLSv1.3
1000 OK: bareos-dir Version: 25.0.2 (date)
Enter a period (.) to cancel a command.
*

Check the status of all configured jobs and daemons:

* status director

This shows scheduled jobs, running jobs, and recent job history. Now run the backup job manually:

* run job=BackupLocalFiles level=Full yes

The Director queues the job and returns a Job ID. Monitor the job progress:

* status director

Wait for the job to complete, then list the finished jobs:

* list jobs

A successful backup shows a status of T (Terminated normally). You can see detailed information about the job:

* list jobid=1

Check what files were backed up:

* list files jobid=1

Type quit to exit bconsole when finished.

Step 15: Test a Restore

A backup that has never been tested is not a backup. Run a test restore to confirm everything works end to end. Open bconsole again:

sudo bconsole

Start the restore process:

* restore client=bareos-fd where=/tmp/bareos-restore select all done yes

This command restores all files from the most recent backup to /tmp/bareos-restore instead of overwriting original files. The where parameter is critical during testing – never restore to the original location unless you intend to overwrite production files.

Monitor the restore job:

* status director

Once the restore completes, exit bconsole and verify the restored files exist:

ls -la /tmp/bareos-restore/etc/
ls -la /tmp/bareos-restore/home/

The restored files should match the original files in content and permissions. Clean up the test restore when satisfied:

sudo rm -rf /tmp/bareos-restore

Step 16: Configure Firewall Rules

Bareos uses three TCP ports for communication between its daemons. Open these ports in the Ubuntu firewall:

  • 9101/tcp – Director daemon
  • 9102/tcp – File Daemon
  • 9103/tcp – Storage Daemon
sudo ufw allow 9101/tcp comment "Bareos Director"
sudo ufw allow 9102/tcp comment "Bareos File Daemon"
sudo ufw allow 9103/tcp comment "Bareos Storage Daemon"
sudo ufw allow 443/tcp comment "HTTPS WebUI"
sudo ufw reload

Verify the rules are active:

sudo ufw status

The output should show all four ports allowed:

Status: active

To                         Action      From
--                         ------      ----
9101/tcp                   ALLOW       Anywhere       # Bareos Director
9102/tcp                   ALLOW       Anywhere       # Bareos File Daemon
9103/tcp                   ALLOW       Anywhere       # Bareos Storage Daemon
443/tcp                    ALLOW       Anywhere       # HTTPS WebUI

In production, restrict ports 9101-9103 to only the IP addresses of your Bareos clients and servers rather than allowing from anywhere.

Step 17: Set Up Bareos WebUI

The Bareos WebUI provides a browser-based dashboard for monitoring jobs, browsing backups, and running restores. It is a PHP application that runs under Apache. The bareos-webui package was already installed in Step 3.

Create a WebUI Admin User

Bareos WebUI authenticates against the Director using a named console resource. Create a dedicated admin console for the web interface:

sudo vi /etc/bareos/bareos-dir.d/console/admin.conf

Add the following configuration:

Console {
  Name = "admin"
  Password = "YourStrongPasswordHere"
  Profile = "webui-admin"
  TLS Enable = no
}

Replace YourStrongPasswordHere with a strong password. The webui-admin profile is created automatically during installation and grants full access to the WebUI.

The corresponding WebUI Director configuration is already in place at /etc/bareos/bareos-dir.d/profile/webui-admin.conf. Reload the Director to apply the new console:

sudo systemctl reload bareos-director

Enable Apache and PHP

The Bareos WebUI package installs an Apache configuration file automatically. Enable the required Apache modules and the Bareos site:

sudo a2enmod rewrite
sudo a2enmod php8.3

On Ubuntu 22.04, the PHP module is php8.1 instead of php8.3:

sudo a2enmod php8.1

The Bareos WebUI Apache configuration is placed at /etc/apache2/conf-available/bareos-webui.conf. Enable it:

sudo a2enconf bareos-webui
sudo systemctl restart apache2

Configure SSL for the WebUI

Running the WebUI over plain HTTP exposes login credentials on the network. Set up SSL with a self-signed certificate for internal use, or use Let’s Encrypt for a public-facing server.

Enable the SSL module and default SSL site:

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo systemctl reload apache2

For a production deployment with a domain name, install certbot and obtain a Let’s Encrypt certificate:

sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d bareos.example.com --non-interactive --agree-tos -m [email protected]

Verify certificate auto-renewal is working:

sudo certbot renew --dry-run

Make sure port 443 is open in the firewall (already done in Step 16).

Access the Bareos WebUI

Open your browser and navigate to https://your-server-ip/bareos-webui/. Log in with the credentials you configured:

  • Username: admin
  • Password: the password you set in admin.conf
  • Director: localhost-dir (or the name shown in the dropdown)

After logging in, the dashboard shows an overview of recent jobs, client status, and storage usage. From the WebUI you can:

  • Monitor running and completed jobs
  • Browse backed-up files and initiate restores
  • View client and storage status
  • Run backup jobs on demand
  • Review job logs and statistics

Step 18: Add a Remote Backup Client

To back up additional machines, install the File Daemon on each remote client and register it with the Director.

On the remote client (Ubuntu), add the Bareos repository and install the File Daemon:

wget -qO /tmp/add_bareos_repositories.sh https://download.bareos.org/current/xUbuntu_24.04/add_bareos_repositories.sh
sudo bash /tmp/add_bareos_repositories.sh
sudo apt update
sudo apt install -y bareos-filedaemon

On the Director server, create a client resource for the remote machine. Replace the IP address and hostname with your actual values:

sudo vi /etc/bareos/bareos-dir.d/client/webserver-fd.conf

Add the following client definition:

Client {
  Name = "webserver-fd"
  Address = "10.0.1.20"
  Password = "ClientPasswordHere"
}

On the remote client, configure the File Daemon to accept connections from the Director:

sudo vi /etc/bareos/bareos-fd.d/director/bareos-dir.conf

Update the Director resource with the matching password:

Director {
  Name = bareos-dir
  Password = "ClientPasswordHere"
}

The password must match exactly between the Director’s client resource and the File Daemon’s director resource. Restart the File Daemon on the remote client:

sudo systemctl enable --now bareos-filedaemon
sudo systemctl restart bareos-filedaemon

Open port 9102 on the remote client’s firewall:

sudo ufw allow 9102/tcp comment "Bareos File Daemon"
sudo ufw reload

Back on the Director server, reload and verify the connection:

sudo systemctl reload bareos-director
sudo bconsole

Check the client status from bconsole:

* status client=webserver-fd

If the connection is successful, you will see the client’s version and job history. Then create a backup job for this client using the same pattern shown in Step 10.

Step 19: Configure Email Notifications

Bareos can send email notifications when jobs complete or fail. Edit the Messages resource in the Director configuration:

sudo vi /etc/bareos/bareos-dir.d/messages/Standard.conf

Update the mail directive with your email address:

Messages {
  Name = Standard
  Mail Command = "/usr/sbin/bsmtp -h localhost -f [email protected] -s \"Bareos: %t %e of %c %l\" %r"
  Operator Command = "/usr/sbin/bsmtp -h localhost -f [email protected] -s \"Bareos: Intervention needed for %j\" %r"
  mail = [email protected] = all, !skipped
  operator = [email protected] = mount
  console = all, !skipped, !saved
  append = "/var/log/bareos/bareos.log" = all, !skipped
  catalog = all
}

This sends email alerts for all job events except skipped jobs. The bsmtp tool ships with Bareos and handles SMTP delivery. Make sure your server can send mail – install postfix or configure bsmtp to use an external SMTP relay.

Reload the Director to apply:

sudo systemctl reload bareos-director

Useful bconsole Commands

Here is a quick reference of the most commonly used bconsole commands for day-to-day Bareos administration:

CommandDescription
status directorShow Director status, running/scheduled jobs
status client=bareos-fdShow status of a specific client
status storage=FileShow storage daemon and device status
list jobsList all completed jobs
list volumesList all backup volumes
list clientsList all configured clients
run job=BackupLocalFilesRun a backup job interactively
restoreStart an interactive restore session
show jobsShow detailed job resource configuration
reloadReload Director configuration without restart
messagesShow pending console messages

Troubleshooting Common Issues

Director fails to start after configuration changes

Always validate the configuration before restarting:

sudo bareos-dir -t -c /etc/bareos/bareos-dir.d

Check the log file for specific error messages:

sudo tail -50 /var/log/bareos/bareos.log

Database connection errors

If the Director cannot connect to PostgreSQL, verify the database exists and the Bareos user has access:

sudo -u postgres psql -c "SELECT datname FROM pg_database WHERE datname='bareos';"
sudo -u postgres psql -c "SELECT usename FROM pg_user WHERE usename='bareos';"

If either query returns empty, re-run the database initialization scripts from Step 4.

Client connection failures

When the Director cannot reach a File Daemon, check these common causes:

  • Firewall blocking port 9102 on the client
  • Password mismatch between Director client resource and File Daemon director resource
  • Wrong IP address in the client resource
  • File Daemon not running on the client

Test connectivity from the Director server:

nc -zv 10.0.1.20 9102

WebUI login fails

If you cannot log into the WebUI, verify the console resource exists and the Director has been reloaded:

sudo cat /etc/bareos/bareos-dir.d/console/admin.conf
sudo systemctl reload bareos-director

Check Apache error logs for PHP issues:

sudo tail -20 /var/log/apache2/error.log

Storage daemon reports “no volumes available”

This happens when no labeled volumes exist in the pool. Label a new volume from bconsole:

* label volume=Full-0001 pool=Full storage=File

Or set Label Format in the pool configuration to auto-label volumes:

sudo vi /etc/bareos/bareos-dir.d/pool/Full.conf

Add the Label Format directive:

Pool {
  Name = Full
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 365 days
  Maximum Volume Bytes = 50G
  Maximum Volumes = 100
  Label Format = "Full-"
}

FAQ

What is the difference between Bareos and Bacula?

Bareos is a fork of Bacula that started in 2010. It includes features not in the Bacula community edition: a built-in web interface (Bareos WebUI), improved TLS support, passive client mode, NDMP support, and better cloud storage integration. Bareos also has a more active open-source community and more frequent releases.

Can Bareos back up Windows and macOS clients?

Yes. Bareos provides File Daemon packages for Windows and macOS in addition to Linux. The Windows File Daemon supports Volume Shadow Copy (VSS) for consistent backups of open files. Install the platform-specific File Daemon on each client and register it with the Director the same way as a Linux client.

Which ports does Bareos use?

Bareos uses three TCP ports: 9101 for the Director, 9102 for the File Daemon, and 9103 for the Storage Daemon. All communication between daemons is encrypted with TLS by default in Bareos 25.x.

Does Bareos support deduplication?

Bareos 25.x includes a dedupable storage backend that performs block-level deduplication. This can significantly reduce storage requirements when backing up many similar clients. The feature requires the bareos-storage-dedupable package.

How do I upgrade Bareos to a newer version?

Since Bareos is installed from the official repository, standard package management handles upgrades. Run sudo apt update && sudo apt upgrade and Bareos packages will be updated along with everything else. After upgrading, check whether database schema changes are needed by running sudo /usr/lib/bareos/scripts/update_bareos_tables.

Conclusion

You now have a fully functional Bareos backup server on Ubuntu with the Director, Storage Daemon, File Daemon, PostgreSQL catalog, and the WebUI all running and configured. The backup job is tested, a restore has been verified, and the firewall is configured for daemon communication.

For a production deployment, consider these next steps: configure backup retention policies per pool, set up offsite or cloud storage for disaster recovery, add monitoring via Bareos WebUI or Nagios/Zabbix integration, and schedule regular restore tests. The Bareos documentation covers advanced topics like tape libraries, NDMP, VMware integration, and plugin development.

Related Articles

Web Hosting Install Caddy web server on Ubuntu 24.04|22.04|20.04 Storage Best PCIe Gen 4 NVMe M.2 Internal SSDs to buy Containers Running Filerun Storage Sync Server in Docker Container Databases Install PostgreSQL 14 on Ubuntu 22.04 (Jammy Jellyfish)

Leave a Comment

Press ESC to close