Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Backrest Backup Service Setup Guide

This guide walks you through setting up Backrest on TrueNAS Scale to back up both local homelab and remote VPS data to Hetzner Storage Box.

Architecture Overview

  • Backrest runs on: TrueNAS homelab
  • Backs up: Local homelab data + remote VPS data (via SSHFS)
  • Stores backups in: Hetzner Storage Box (via SFTP)
  • Web UI: Accessible at http://homelab-ip:12001

Prerequisites

  • TrueNAS Scale system (homelab)
  • Remote VPS with WireGuard connection to homelab
  • Hetzner Storage Box configured (see Storage Box setup guide)
  • Docker and Dockge installed on TrueNAS
  • FUSE kernel module available (/dev/fuse)
  • SSH key pair for authentication

Part 1: Prepare SSH Keys

Step 1: Generate SSH Key on Homelab

# Create SSH directory for Backrest
mkdir -p ${CONFIG_PATH}/backrest/ssh
chmod 700 ${CONFIG_PATH}/backrest/ssh

# Generate ED25519 key (no passphrase for automation)
ssh-keygen -t ed25519 -f ${CONFIG_PATH}/backrest/ssh/id_ed25519 -N "" -C "backrest-homelab"

# Set correct permissions
chmod 600 ${CONFIG_PATH}/backrest/ssh/id_ed25519
chmod 644 ${CONFIG_PATH}/backrest/ssh/id_ed25519.pub

Step 2: Authorize Key on Storage Box

# Get your public key
cat ${CONFIG_PATH}/backrest/ssh/id_ed25519.pub

# Connect to Storage Box
sftp -P 23 uXXXXXX@uXXXXXX.your-storagebox.de

# In SFTP session:
mkdir .ssh
chmod 700 .ssh
put ${CONFIG_PATH}/backrest/ssh/id_ed25519.pub .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
bye

Step 3: Authorize Key on VPS

# Copy public key to VPS
ssh-copy-id -i ${CONFIG_PATH}/backrest/ssh/id_ed25519.pub root@VPS_IP

# Or manually:
cat ${CONFIG_PATH}/backrest/ssh/id_ed25519.pub | ssh root@VPS_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Step 4: Add Known Hosts

# Add Storage Box to known_hosts
ssh-keyscan -p 23 uXXXXXX.your-storagebox.de | tee ${CONFIG_PATH}/backrest/ssh/known_hosts

# Add VPS to known_hosts
ssh-keyscan VPS_IP >> ${CONFIG_PATH}/backrest/ssh/known_hosts

# Set permissions
chmod 644 ${CONFIG_PATH}/backrest/ssh/known_hosts

Step 5: Set Correct Ownership

# Backrest container runs as root, so files should be owned by root
sudo chown -R root:root ${CONFIG_PATH}/backrest/ssh

Part 2: Enable FUSE Support

SSHFS requires the FUSE kernel module.

Step 1: Load FUSE Module

# Load FUSE module
sudo modprobe fuse

# Verify it loaded
lsmod | grep fuse

# Verify device exists
ls -l /dev/fuse

Should show: crw-rw-rw- 1 root root 10, 229 ...

Step 2: Make FUSE Persistent (Optional)

To ensure FUSE loads on boot:

# Add to modules
echo "fuse" | sudo tee -a /etc/modules

# Or create systemd service
sudo tee /etc/systemd/system/load-fuse.service << 'EOF'
[Unit]
Description=Load FUSE kernel module
Before=docker.service

[Service]
Type=oneshot
ExecStart=/sbin/modprobe fuse
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable load-fuse.service

Part 3: Deploy Backrest with Dockge

Step 1: Create Backrest Stack in Dockge

Create a new stack named backrest with the following compose file:

services:
  backrest:
    image: garethgeorge/backrest:latest
    restart: unless-stopped
    privileged: true
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse
    environment:
      - BACKREST_PORT=0.0.0.0:9898
      - BACKREST_DATA=/data
      - BACKREST_CONFIG=/config/config.json
      - XDG_CACHE_HOME=/cache
      - TZ=Europe/Brussels
    volumes:
      - ${CONFIG_PATH}/backrest/data:/data
      - ${CONFIG_PATH}/backrest/config:/config
      - ${CONFIG_PATH}/backrest/cache:/cache
      - ${CONFIG_PATH}/backrest/ssh:/root/.ssh:ro
      - /mnt/pool:/mnt/pool:ro
    command: >
      sh -c "
      apk add --no-cache sshfs openssh-client &&
      mkdir -p /mnt/vps &&
      sshfs -o allow_other,StrictHostKeyChecking=no,IdentityFile=/root/.ssh/id_ed25519 root@VPS_IP:/ /mnt/vps &
      sleep 2 &&
      exec /backrest
      "
    ports:
      - 12001:9898

networks: {}

Important replacements:

  • Replace VPS_IP with your VPS IP address (preferably WireGuard IP like 10.8.0.1)
  • Replace /mnt/pool with your actual TrueNAS pool mount point
  • Adjust ${CONFIG_PATH} if needed (or use absolute paths)
  • Adjust TZ to your timezone

Step 2: Deploy the Stack

  1. In Dockge, click Deploy
  2. Wait for the container to start
  3. Check logs for any errors

Step 3: Verify SSHFS Mount

# Check if VPS is mounted
sudo docker exec backrest-backrest-1 ls /mnt/vps

# Should show VPS directory structure: bin, etc, opt, var, etc.

Step 4: Verify Backrest is Running

# Check logs
sudo docker logs backrest-backrest-1

# Should see: "starting web server" and "addr": "0.0.0.0:9898"

Part 4: Configure Backrest Repository

Step 1: Access Backrest Web UI

Open your browser and navigate to:

http://homelab-ip:12001

Step 2: Initial Settings

On first launch, configure:

  • Instance ID: homelab-backrest (or any unique name)
  • Authentication: Create a username and password

Click Save.

Step 3: Add Storage Box Repository

  1. Navigate to Repositories → + Add Repo

  2. Fill in the details:

    Repo Details:

    • Repo Name: tnt-backup (or your preferred name)
    • Repository URI: sftp://uXXXXXX@uXXXXXX.your-storagebox.de:23/tnt-backup
      • Replace uXXXXXX with your Storage Box username
      • The /tnt-backup path will be created automatically

    Password:

    • Click [Generate] to create a strong encryption password
    • CRITICAL: Copy this password and store it securely!
    • Without this password, your backups are permanently unrecoverable

    Auto Unlock:

    • ✅ Check this box (for single-user setup)
  3. Click Test Configuration

    • Should show success
  4. Click Submit

    • Repository will be initialized

Part 5: Create Backup Plans

Homelab Backup Plan

  1. Navigate to Plans → + Add Plan

  2. Configure:

    Plan Details:

    • Plan Name: homelab-backup
    • Repository: tnt-backup

    Backup Scope:

    • Paths: Add the following:

      • /mnt/pool/docker
      • /mnt/pool/appdata
      • (Add other important directories)
    • Excludes: Add the following:

      • /mnt/pool/media (if media is large and not critical)
      • *.log
      • *.tmp
      • cache/
      • .cache/

    Backup Schedule:

    • Schedule Type: Cron
    • Cron Expression: 0 3 * * 0 (Sunday at 3 AM)
    • Reference Clock: Local

    Retention Policy:

    • By Time Period (selected)
    • Hourly: 0
    • Daily: 7
    • Weekly: 4
    • Monthly: 6
    • Yearly: 0
  3. Click Submit

VPS Backup Plan

  1. Navigate to Plans → + Add Plan

  2. Configure:

    Plan Details:

    • Plan Name: vps-backup
    • Repository: tnt-backup

    Backup Scope:

    • Paths: Add the following:

      • /mnt/vps/opt/docker
      • /mnt/vps/etc
    • Excludes: Add the following:

      • *.log
      • *.tmp
      • cache/
      • .cache/

    Backup Schedule:

    • Schedule Type: Cron
    • Cron Expression: 0 2 * * 0 (Sunday at 2 AM - 1 hour before homelab)
    • Reference Clock: Local

    Retention Policy:

    • By Time Period (selected)
    • Hourly: 0
    • Daily: 7
    • Weekly: 4
    • Monthly: 6
    • Yearly: 0
  3. Click Submit

Using Healthchecks.io

  1. Create account at Healthchecks.io

  2. Create a check for each backup plan:

    • Name: Homelab Backup
    • Schedule: Weekly
    • Grace Time: 2 hours
  3. In Backrest, edit each backup plan:

    • Go to Advanced → Hooks
    • Click + Add Hook
    • On Success: HTTP GET to healthcheck URL
    • On Error: HTTP GET to healthcheck URL/fail
  4. Save the plan

This will alert you if:

  • Backups fail to run
  • Backups complete with errors
  • Backups don’t run on schedule

Part 7: Testing

Test Manual Backup

  1. In Backrest UI, navigate to Plans
  2. Click on homelab-backup
  3. Click Backup Now
  4. Monitor the progress in the UI
  5. Verify backup completes successfully

Repeat for vps-backup.

Test Restore

  1. Navigate to Plans → Select a plan
  2. Click on a completed backup snapshot
  3. Browse files in the backup
  4. Select a file and click Restore
  5. Verify file is restored

Maintenance

Regular Checks

  • Weekly: Check backup logs for successful completion
  • Monthly: Run restic check via Backrest to verify repository integrity
  • Quarterly: Test a full restore operation

Monitoring Storage Usage

  1. Check Storage Box usage in Hetzner Console
  2. Monitor disk graphs in Backrest dashboard
  3. Adjust retention policy if space becomes constrained

Updating Backrest

When new versions are released:

  1. In Dockge, update image tag or pull latest
  2. Redeploy the stack
  3. Verify backups continue to run

Troubleshooting

Container Won’t Start

# Check logs
sudo docker logs backrest-backrest-1

# Common issues:
# - FUSE module not loaded: sudo modprobe fuse
# - SSH key permissions wrong: sudo chown -R root:root ${CONFIG_PATH}/backrest/ssh
# - VPS unreachable: Check WireGuard connection

SSHFS Mount Failed

# Test SSH connection to VPS
ssh -i ${CONFIG_PATH}/backrest/ssh/id_ed25519 root@VPS_IP

# If fails, check:
# - SSH key authorized on VPS
# - VPS firewall allows SSH
# - WireGuard tunnel is up

Backups Failing

# Check Backrest logs
sudo docker logs backrest-backrest-1

# Test Storage Box connection
ssh -p 23 -i ${CONFIG_PATH}/backrest/ssh/id_ed25519 uXXXXXX@uXXXXXX.your-storagebox.de ls

# Verify External Reachability is enabled in Hetzner Console

Web UI Not Accessible

# Verify BACKREST_PORT is set to 0.0.0.0:9898
sudo docker exec backrest-backrest-1 env | grep BACKREST_PORT

# Check if port is listening
sudo docker exec backrest-backrest-1 netstat -tlnp | grep 9898

Security Considerations

  1. SSH Keys: Keep private keys secure, use different keys per machine
  2. Encryption Password: Store Restic password in password manager
  3. Network: Backrest UI has authentication enabled
  4. Updates: Keep Backrest and base images updated
  5. Access: Limit who can access Backrest web UI

Performance Tips

  1. Exclude Large Files: Don’t back up media files unless necessary
  2. Adjust Schedules: Space out backup times to reduce load
  3. Retention: Balance between backup history and storage costs
  4. Network: Use WireGuard IP for VPS connection (faster than public internet)

Backup Strategy Summary

What’s Backed Up:

  • ✅ Homelab Docker configurations and data
  • ✅ Homelab application data
  • ✅ VPS Docker configurations
  • ✅ VPS system configurations (/etc)
  • ❌ Media files (too large, can be re-downloaded)

Backup Frequency:

  • Weekly automatic backups (Sunday nights)

Retention:

  • 7 daily backups (~1 week of daily history)
  • 4 weekly backups (~1 month of weekly history)
  • 6 monthly backups (~6 months of long-term history)

Recovery Time:

  • Configs/small files: Minutes
  • Large datasets: Hours (depends on internet speed)

Cost Breakdown

  • Hetzner Storage Box BX11: €3.87/month (1TB)
  • Total monthly cost: €3.87

For automated, encrypted, off-site backups of critical infrastructure.

Next Steps

After setup is complete:

  1. ✅ Test backups run successfully
  2. ✅ Verify notifications work
  3. ✅ Document your Restic encryption password securely
  4. ✅ Test a restore operation
  5. ✅ Set calendar reminders for quarterly restore tests

Additional Resources