Setup for using Borgbackup with Hetzner Storage Box. I use Hetzner's Storage Box solution (Robot) for my backups. Borgbackup is a deduplicating backup program that provides efficient and secure backups.
Key features:
- Deduplication (saves storage space)
- Compression
- Encryption
- Incremental backups
- Remote backup support
Backups are performed by the
Clan framework using
clan.core.state.<SERVICENAME>. This allows executing actions before the backup
and after restoration of files.
The backup process:
- Stops services (systemd services or podman containers)
- Creates a synchronized copy in
/var/backup/<SERVICENAME> - Restarts services
- Backs up the
/var/backup/<SERVICENAME>data using Borgbackup to Hetzner Storage Box
To manually trigger a backup for a server:
clan backups create <SERVERNAME>This will backup all configured services on the specified server.
List all available backups:
clan backups list <SERVERNAME>Example output:
storagebox::u444061@u444061.your-storagebox.de:/./borgbackup::<SERVERNAME>-storagebox-2025-07-24T01:00:00
storagebox::u444061@u444061.your-storagebox.de:/./borgbackup::<SERVERNAME>-storagebox-2025-07-24T06:02:35
storagebox::u444061@u444061.your-storagebox.de:/./borgbackup::<SERVERNAME>-storagebox-2025-07-25T01:00:02
To restore only one specific service:
clan backups restore --service <SERVICENAME> <SERVERNAME> borgbackup \
storagebox::u444061@u444061.your-storagebox.de:/./borgbackup::<SERVERNAME>-storagebox-2025-07-24T06:02:35This is useful when you only need to restore a specific application (e.g., dokuwiki, lldap).
To restore all services from a backup:
clan backups restore <SERVERNAME> borgbackup \
storagebox::u444061@u444061.your-storagebox.de:/./borgbackup::<SERVERNAME>-storagebox-2025-07-24T06:02:35Warning: This will restore ALL services and may overwrite current data.
To see when the next automatic backups are scheduled:
# On the host server
systemctl list-timers | grep -E 'NEXT|borg'This shows all borgbackup timers and their next execution time.
- Go to https://robot.hetzner.com/
- Order a new Storage Box
- You will receive:
- Account ID (e.g.,
u444061) - URL:
<USERNAME>.your-storagebox.de - Initial password
- Account ID (e.g.,
To simplify backup management, I use a single SSH key shared across the homelab infrastructure. This allows services to move between hosts without changing SSH keys.
The SSH key and Borg passphrase are generated by Clan and shared across hosts.
# Deploy the server configuration (generates SSH keys)
clan machines update <SERVERNAME>
# Install the public key on the Storage Box
clan vars get <SERVERNAME> borgbackup/borgbackup/borgbackup.ssh.pub | \
ssh -p23 <USERNAME>.your-storagebox.de install-ssh-keyReplace <USERNAME> with your actual Storage Box username (e.g., u444061).
Verify that SSH access is working correctly:
# Test SSH connection
clan vars get <SERVERNAME> borgbackup/borgbackup/borgbackup.ssh > /tmp/ssh && \
chmod 600 /tmp/ssh && \
ssh -i /tmp/ssh -p23 <USERNAME>@<USERNAME>.your-storagebox.de ls -alh && \
rm -f /tmp/sshIf successful, you should see a directory listing from the Storage Box.
Check that:
- SSH key is properly installed on Storage Box
- Storage Box is accessible:
ping <USERNAME>.your-storagebox.de - Port 23 is not blocked by firewall
# Check backup service status
systemctl status borgbackup-<SERVICENAME>
# View backup logs
journalctl -u borgbackup-<SERVICENAME> -fIf you get a "repository is locked" error:
# List locks
borg list storagebox::u444061@u444061.your-storagebox.de:/./borgbackup
# Break lock (use with caution!)
borg break-lock storagebox::u444061@u444061.your-storagebox.de:/./borgbackupWarning: Only break locks if you're certain no backup is running.