HDD-Housing e.U.

BorgBackup to S3 storage (Borg 1.4 with rclone)

BorgBackup (Borg) offers space-efficient, deduplicated and encrypted backups with compression (lz4, zstd, zlib, lzma) and backups you can mount via FUSE. It is free software (BSD license) and available for Linux, macOS and FreeBSD.

Borg and S3

The current stable version, Borg 1.4, cannot write to S3 storage directly – it only supports local repositories and SSH. S3 support is coming with Borg 2, which is still in beta and not intended for production use.

With Borg 1.4, the proven approach is: back up to a local repository first, then sync it to your HDD-Housing S3 storage with rclone.

1. Create a local Borg repository

apt install borgbackup
borg init --encryption=repokey-blake2 /backup/borg-repo
borg key export /backup/borg-repo /root/borg-key.txt

Important: Store the passphrase and the exported key safely outside the backed-up system. Without them, your backup cannot be restored.

2. Configure rclone

Install rclone and add a remote to ~/.config/rclone/rclone.conf:

[hddhousing]
type = s3
provider = Other
access_key_id = access_key
secret_access_key = secret_key
endpoint = http://IP-OR-DNS:7070

Replace access_key, secret_key and IP-OR-DNS with the values you receive with your account.

3. Backup script

#!/bin/bash
export BORG_PASSPHRASE="your_passphrase"
REPO=/backup/borg-repo

borg create --stats --compression zstd $REPO::{hostname}-{now} /etc /home
borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6 $REPO
borg compact $REPO

rclone sync $REPO hddhousing:bucket/borg-repo

rclone sync mirrors the local repository – including deletions. Older states remain available on our side through the ZFS snapshots, which cannot be deleted via S3.