Marinus Klasen

Marinus Klasen

  • WordStress
  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

January 2, 2026

Backup a full server to Hetzner Storage Boxes

Marinus Klasen

I recently needed to completely reinstall one of my Hetzner servers with Proxmox, but first wanted to make sure I had a bulletproof backup of everything on it. After hitting a few roadblocks with Borg backup, here’s the solution I ended up with.

The main issue I ran into was trying to create the backup repository in /data/storage – turns out Borg can’t create a repository inside a directory it’s trying to backup (circular reference problem). The solution? Use Hetzner’s Storage Box service as the backup destination.

Setting up the backup

First, install Borg if you haven’t already:

apt update && apt install borgbackup

Then set up your Storage Box credentials as environment variables:

export STORAGE_USER="uXXXXXX"  # Your storage box username
export STORAGE_HOST="uXXXXXX.your-storagebox.de"  # Your storage box hostname
export BORG_REPO="ssh://${STORAGE_USER}@${STORAGE_HOST}:23/./backups/server-full"
export BORG_PASSPHRASE="choose-a-strong-passphrase"

The ./ in the path means “relative to home directory” – so it’ll create the backup in /home/uXXXXXX/backups/server-full on your Storage Box.

Creating the backup repository

First, create the directory on your Storage Box:

ssh -p 23 ${STORAGE_USER}@${STORAGE_HOST} mkdir -p backups

Then initialize the Borg repository:

borg init --encryption=repokey-blake2

This creates an encrypted repository that’ll hold all your backup archives.

Running the actual backup

Now for the main event – backing up your entire server:

borg create --progress --stats \
  --exclude /dev \
  --exclude /proc \
  --exclude /sys \
  --exclude /tmp \
  --exclude /run \
  --exclude /mnt \
  --exclude /media \
  --exclude /var/cache \
  --exclude /swapfile \
  ::{hostname}-{now} \
  / /etc /root /home /var /usr/local /opt /srv /data

This excludes the system directories that shouldn’t be backed up and creates an archive named with your hostname and timestamp. The backup will take some time depending on your server size – grab a coffee!

Don’t forget the encryption key!

This is crucial – export and save your Borg encryption key:

borg key export :: /tmp/borg-key.txt
scp -P 23 /tmp/borg-key.txt ${STORAGE_USER}@${STORAGE_HOST}:backups/

Without this key, your backups are useless, so keep it safe!

Verifying and restoring

To verify your backup worked:

borg list
borg info ::{archive-name}

And when you need to restore after installing Proxmox:

borg mount ::{archive-name} /mnt/restore
# Then copy needed files back

The mount command lets you browse the backup like a normal filesystem – super handy for selective restoration.

Happy backing up!

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Looking for a WordPress expert?
Hire top notch developers on Codeable!

Consult an expert

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get in touch

Contact me using the details below

Marinus Klasen

Wilhelmina van Pruisenweg 35, 2595 AN Den Haag

marinus@mklasen.com
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Backup a full server to Hetzner Storage BoxesJanuary 2, 2026
  • Music I loveDecember 29, 2025
  • Running Github Actions and Workflows LocallyAugust 25, 2025
  • Elementor Widget UsageMarch 27, 2025
  • Programmatically showing popups with ElementorMarch 25, 2025

Copyright © 2026 ยท Marinus Klasen | Webdesign by Team Rood