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:
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.confSection A — Connect Bareos with Hetzner Object Storage
-
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.
-
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
-
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-dplcompatas 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-dplcompatDuring 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-filedaemonCheck 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 bareosWhen it asks for the password, enter the PostgreSQL application password for bareos-database-common that you set during the Bareos installation above.
-
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 lsIf you get an error message like
s3cmd: command not found, create a symbolic link to yours3cmdexecutable and try again:sudo ln -s $(which s3cmd) /usr/local/bin/s3cmd sudo -u $USER s3cmd lsNext, 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
-
Create Device Resource and Storage Resource
-
sudo cp -a /etc/bareos/bareos-sd.d/device/dplcompat.conf.example /etc/bareos/bareos-sd.d/device/HetznerBucket_BareosDevice.confEdit the copied content:
- Set
HetznerBucket_BareosDeviceas "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" } - Set
-
sudo cp -a /etc/bareos/bareos-dir.d/storage/dplcompat.conf.example /etc/bareos/bareos-dir.d/storage/HetznerBucket_BareosStorage.confEdit the copied content:
- Set
HetznerBucket_BareosStorageas "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 } - Set
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 -
-
Test connection
- Open the Bareos console
This opens the interactive console. You should now see a prompt that starts with a
sudo bconsole*.
- Check status
The output should mention
status storage=HetznerBucket_BareosStorageBackend 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.
- Open the Bareos console
Section B — Define backup schedule and select data to back up
-
Create test files
Create a new directory called
subdirand a new file calledtest-file.txtto 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
-
Create backup resources
-
/etc/bareos/bareos-dir.d/fileset/HetznerBucket_BareosFileSet.confFileSet { 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 } } -
/etc/bareos/bareos-dir.d/job/HetznerBucket_BareosJob.confJob { Name = "HetznerBucket_BareosJob" Type = Backup Pool = Full Messages = Standard Client = bareos-fd FileSet = "HetznerBucket_BareosFileSet" Schedule = "HetznerBucket_BareosSchedule" Storage = "HetznerBucket_BareosStorage" } -
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
timedatectlto 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.confSchedule { 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.
-
-
Reload
sudo -u bareos bareos-dir -t sudo systemctl restart bareos-director sudo systemctl status bareos-directorNow wait until the time set in
HetznerBucket_BareosSchedule.conffor "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.txtAfter the file is added, wait until the time set in
HetznerBucket_BareosSchedule.conffor "Incremental" has passed. After the time has passed, continue with the next step, which explains how to view all jobs.
-
View jobs
-
Open the Bareos console
sudo bconsoleYou 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
-
Restore backups
- Job Resource
/etc/bareos/bareos-dir.d/job/HetznerBucket_BareosRestoreJob.confAfter you saved the file, create a repository for the restored backups and reload again: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 }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
This opens the interactive console. You should now see a prompt that starts with a
sudo bconsole*.
-
Restore a specific job ID
First, list available jobs:
list jobs job=HetznerBucket_BareosJobPick 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): 1In
bconsole, you can runmessagesto 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 - Restore full backup:
- Job Resource
Your data should now be backed up automatically at the times specified in /etc/bareos/bareos-dir.d/schedule/HetznerBucket_BareosSchedule.conf.