stuff/homeservers/Backup.md
Moni Ghaoui 126ad4e01b x
2025-06-29 20:08:28 +02:00

2.2 KiB

Borg Backup to Hetzner Storage Box

For backup I use Borg. I followed the steps described in this community article:

We have two backups in the storage box:

  • /./borgbackup/photoprism
  • /./borgbackup/nextcloud

Photoprism backup

This is what I did for Photoprism

The init script (which is only done once, be careful it will overwrite!):

# (As root)
export BORG_RSH='ssh -i /root/.ssh/id_ed25519'
export BORG_PASSPHRASE="<I GENERATED A PASSPHRASE>"
borg init --encryption=repokey ssh://u388089@u388089.your-storagebox.de:23/./borgbackup/photoprism

It outputs a key which I put in Bitwarden (you need it to decrypt the backup).

To make a manual backup:

export BORG_RSH='ssh -i /root/.ssh/id_ed25519'
export BORG_PASSPHRASE="<SEE BITWARDEN>"
borg create --stats ssh://u388089@u388089.your-storagebox.de:23/./borgbackup/photoprism::2024_11_24 /home/photoprism/Import/ /home/photoprism/Pictures/

The above can be found in Bitwarden, look for "Hetzner Borg Backup Script for Photoprism"

I also created a bash script in /usr/local/bin/photoprism_backup.sh (as mentioned in the article).

You can find it here in this repo:

Nextcloud backup

Ok, this is confusing but Nextcloud uses Borgbackup internally. Go to the aio interface and you'll notice there are backups to:

/root/nextcloudbackup

So nextcloud keeps making backups to this directory. Not ideal (TODO: I gotta find a solution for this).

But I can rclone the data:

rclone sync -v /root/nextcloudbackup/ hetzner:/cloned_borgbackup/nextcloud

For this I also created a script and placed it in /usr/local/bin

nextcloud_backup.sh

Automatic backup

cp -v cloud_backup.service /etc/systemd/system/
cp -v cloud_backup.timer /etc/systemd/system/
systemctl enable cloud_backup.service
systemctl enable cloud_backup.timer