Setting up Bareos

Last change on 2026-02-09 • Created on 2026-02-09 • ID: ST-330D6

Because of their scalability and high-availability, Buckets are a great option for storing backups.

Bareos is an open-source, fast and secure backup program for local and remote directories or files. It uses encryption to protect your backups, ensuring that only you can access the data. For more information about Bareos, see:

Bareos offers different solutions for S3:

Dplcompat Storage Backend
Available since Bareos 24

Apache Libcloud Plugin
Supports S3 since Bareos 25

This how-to guide will focus on Dplcompat Storage Backend.

By the end of this how-to guide, you will have the following files:

/etc/bareos/bareos-sd.d/
└── device/HetznerBucket_BareosDevice.conf      # Describes how Bareos can access the S3-compatible object storage

/etc/bareos/bareos-dir.d/
├── storage/
|   └── HetznerBucket_BareosStorage.conf
|
├── fileset/
|   └── HetznerBucket_BareosFileSet.conf        # Defines which files are backed up
├── schedule/
|   └── HetznerBucket_BareosSchedule.conf       # Defines when the backup job runs (day and time)
└── job/
    ├── HetznerBucket_BareosJob.conf
    └── HetznerBucket_BareosRestoreJob.conf

Section A — Connect Bareos with Hetzner Object Storage

  1. Create your credentials

    For a step-by-step guide, see the getting started article "Generating S3 credentials".

    Make sure you save the credentials in a safe location right after you create them. You cannot view the secret key again, neither via Hetzner Console nor via API.


  1. Install PostgreSQL

    You can follow the official instructions at postgresql.org. For example on Ubuntu:

    sudo apt update
    sudo apt install postgresql
    sudo systemctl status postgresql

  1. Install Bareos and Bareos Dplcompat Storage Backend

    If you haven't already, install Bareos now. You can follow the official instructions at docs.bareos.org. Install bareos-storage-dplcompat as well, for S3-compatible storage. For example on Ubuntu:

    wget https://download.bareos.org/current/xUbuntu_24.04/add_bareos_repositories.sh
    sudo sh ./add_bareos_repositories.sh
    sudo apt update
    sudo apt install bareos dbconfig-common bareos-storage-dplcompat

    During the installation, you will be prompted for the following:

    Option
    Mail server configuration Pick whatever fits your needs best. This tutorial was tested with "No configuration"
    Configure database for bareos-database-common with dbconfig-common? Yes
    Host name of the PostgreSQL database server for bareos-database-common localhost
    PostgreSQL application password for bareos-database-common Enter a secure password of your choice
    Password confirmation Re-enter the password you just set in the step before

    Start the service and check the status:

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

    Check if the database was setup properly:

    sudo -u postgres psql -l | grep bareos
    sudo -u postgres psql -c "\du" | grep bareos
    psql -h localhost -U bareos -d bareos

    When it asks for the password, enter the PostgreSQL application password for bareos-database-common that you set during the Bareos installation above.


  1. Install S3-compatible CLI tool

    If you haven't already, install S3cmd as explained in the getting started "Using S3-compatible CLI tools".

    Once S3cmd is installed, make sure it also works when run as a different user:

    sudo -u $USER s3cmd ls

    If you get an error message like s3cmd: command not found, create a symbolic link to your s3cmd executable and try again:

    sudo ln -s $(which s3cmd) /usr/local/bin/s3cmd
    sudo -u $USER s3cmd ls

    Next, setup the Dplcompat Wrapper Program.

    The official BareOS docs explain how to use s3cmd-wrapper.sh. For example:

    sudo cp ~/.s3cfg /etc/bareos/s3cfg
    sudo chown bareos /etc/bareos/s3cfg
    sudo -u bareos s3cmd --config /etc/bareos/s3cfg ls
    sudo s3cfg=/etc/bareos/s3cfg \
         bucket=<your_bucket_name> \
         -u bareos \
         /usr/lib/bareos/scripts/s3cmd-wrapper.sh \
         testconnection

  1. Create Device Resource and Storage Resource

    • Device Resource

      sudo cp -a /etc/bareos/bareos-sd.d/device/dplcompat.conf.example /etc/bareos/bareos-sd.d/device/HetznerBucket_BareosDevice.conf

      Edit the copied content:

      • Set HetznerBucket_BareosDevice as "Name".
      • Replace <your_bucket_name> with the name of your Bucket.
      • Remove storage_class.
      # /etc/bareos/bareos-sd.d/device/HetznerBucket_BareosDevice.conf
      Device {
        Name = HetznerBucket_BareosDevice
        Media Type = dplcompat
        Archive Device = S3 Object Storage
        Device Options = "iothreads=4"
                         ",ioslots=2"
                         ",chunksize=262144000"
                         ",program=s3cmd-wrapper.sh"
                         ",s3cfg=/etc/bareos/s3cfg"
                         ",bucket=<your_bucket_name>"
        Device Type = dplcompat
        Label Media = yes
        Random Access = yes
        Automatic Mount = yes
        Removable Media = no
        Always Open = no
        Description = "droplet compatible device"
      }
    • Storage Resource

      sudo cp -a /etc/bareos/bareos-dir.d/storage/dplcompat.conf.example /etc/bareos/bareos-dir.d/storage/HetznerBucket_BareosStorage.conf

      Edit the copied content:

      • Set HetznerBucket_BareosStorage as "Name".
      • Replace the values of Address and Password with the values provided in /etc/bareos/bareos-dir.d/storage/File.conf.
      • Replace the Device with the name of the device you just created above.
      Storage {
        Name = HetznerBucket_BareosStorage
        Address  = "example-server"
        Password = "<your_password>"
        Device = HetznerBucket_BareosDevice
        Media Type = dplcompat
      }

    Now do a restart and check the status afterwards:

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

  1. Test connection

    • Open the Bareos console
      sudo bconsole
      This opens the interactive console. You should now see a prompt that starts with a *.

    • Check status
      status storage=HetznerBucket_BareosStorage
      The output should mention Backend connection is working.

    • Use existing backup job to test the creation of backups
      run job=backup-bareos-fd storage=HetznerBucket_BareosStorage level=Full

    If the backup appears in your Bucket, the connection is working. You can now define a schedule and choose which files should be backed up.


Section B — Define backup schedule and select data to back up

  1. Create test files

    Create a new directory called subdir and a new file called test-file.txt to test backups of specific data. Add some text in the test file.

    mkdir -p "/tmp/backup/subdir"
    touch "/tmp/backup"/{test-file.1.txt,subdir/{test-file.2.txt,dont-backup.txt}}
    /tmp/backup/
    ├── test-file.1.txt
    └── subdir/
        ├── test-file.2.txt
        └── dont-backup.txt

  1. Create backup resources

    • FileSet Resource

      /etc/bareos/bareos-dir.d/fileset/HetznerBucket_BareosFileSet.conf
      FileSet {
        Name = "HetznerBucket_BareosFileSet"
        Include {
          Options {
            signature = XXH128
          }
          File = /tmp/backup/test-file.1.txt
          File = /tmp/backup/subdir
        }
        Exclude {
          File = /tmp/backup/subdir/dont-backup.txt
        }
      }
    • Job Resource

      /etc/bareos/bareos-dir.d/job/HetznerBucket_BareosJob.conf
      Job {
        Name = "HetznerBucket_BareosJob"
        Type = Backup
        Pool = Full
        Messages = Standard
        Client = bareos-fd
        FileSet = "HetznerBucket_BareosFileSet"
        Schedule = "HetznerBucket_BareosSchedule"
        Storage = "HetznerBucket_BareosStorage"
      }
    • Schedule Resource

      For testing purposes, we will set the schedule to run a full backup in two minutes from now and an incremental backup in four minutes from now. In the example below, it is assumed that the current time is Tuesday 12:58. Before creating the Schedule Resource, run timedatectl to check the current time on your system. Adapt the time in the example body below to match your own time.

      /etc/bareos/bareos-dir.d/schedule/HetznerBucket_BareosSchedule.conf
      Schedule {
        Name = "HetznerBucket_BareosSchedule"
        Run = Full tue at 13:00
        Run = Incremental tue at 13:02
      }

      For more information about supported date-time-specifications, see the official Bareos documentation.


  1. Reload

    sudo -u bareos bareos-dir -t
    sudo systemctl restart bareos-director
    sudo systemctl status bareos-director

    Now wait until the time set in HetznerBucket_BareosSchedule.conf for "Full" has passed. After the time has passed, the backup should appear in your Bucket.

    Once the Backup appeared, add another file in the directory that is getting backed up so that you can test the incremental backup as well.

    touch /tmp/backup/subdir/new.txt

    After the file is added, wait until the time set in HetznerBucket_BareosSchedule.conf for "Incremental" has passed. After the time has passed, continue with the next step, which explains how to view all jobs.


  1. View jobs

    • Open the Bareos console

      sudo bconsole

      You should now see a prompt that starts with a *. Run the following command to view the jobs:

      *list jobs
      Automatically selected Catalog: MyCatalog
      Using Catalog "MyCatalog"
      +-------+-------------------------+-----------+---------------------+----------+------+-------+----------+------------+-----------+
      | jobid | name                    | client    | starttime           | duration | type | level | jobfiles | jobbytes   | jobstatus |
      +-------+-------------------------+-----------+---------------------+----------+------+-------+----------+------------+-----------+
      |     1 | backup-bareos-fd        | bareos-fd | 2026-02-16 12:15:09 | 00:00:24 | B    | F     |      444 | 37,520,807 | T         |
      |     2 | HetznerBucket_BareosJob | bareos-fd | 2026-02-16 12:43:02 | 00:00:14 | B    | F     |        3 |         20 | T         |
      |     3 | HetznerBucket_BareosJob | bareos-fd | 2026-02-16 12:56:02 | 00:00:15 | B    | I     |        2 |          4 | T         |
      +-------+-------------------------+-----------+---------------------+----------+------+-------+----------+------------+-----------+

      In the example above, the third job created the incremental backup.

      If you need to troubleshoot, try these commands in bconsole:

      *messages
      *status dir

Section C — Restore backups

  1. Restore backups

    • Job Resource
      /etc/bareos/bareos-dir.d/job/HetznerBucket_BareosRestoreJob.conf
      Job {
        Name = "HetznerBucket_BareosRestoreJob"
        Type = Restore
        Pool = Full
        Messages = Standard
        Client = bareos-fd
        FileSet = "HetznerBucket_BareosFileSet"
        Storage = HetznerBucket_BareosStorage
        Where = /tmp/backup-restore
        Maximum Concurrent Jobs = 10
      }
      After you saved the file, create a repository for the restored backups and reload again:
      sudo mkdir /tmp/backup-restore
      sudo -u bareos bareos-dir -t
      sudo systemctl restart bareos-director
      sudo systemctl status bareos-director

    • Open the Bareos console
      sudo bconsole
      This opens the interactive console. You should now see a prompt that starts with a *.

    • Restore a specific job ID

      First, list available jobs:

      list jobs job=HetznerBucket_BareosJob

      Pick a job ID and restore the respective files. If you want to restore incremental backups, you can specify several job IDs separated by a comma.

      • Restore full backup:
        restore jobid=2 all done yes
      • Restore full and incremental backup:
        restore jobid=2,3 all done yes

      When it asks you which Restore Job to use, select "HetznerBucket_BareosRestoreJob":

      Building directory tree for JobId(s) 2 ...
      2 files inserted into the tree and marked for extraction.
      The defined Restore Job resources are:
      1: HetznerBucket_BareosRestoreJob
      2: RestoreFiles
      Select Restore Job (1-2): 1

      In bconsole, you can run messages to view the status.

      Once the restore is complete, view the restored files:

      sudo ls /tmp/backup-restore/tmp/backup
      sudo ls /tmp/backup-restore/tmp/backup/subdir

Your data should now be backed up automatically at the times specified in /etc/bareos/bareos-dir.d/schedule/HetznerBucket_BareosSchedule.conf.

Table of Contents