Backup & restore

Configuration as of 2026-11-07. Every server backs up daily with borgmatic on top of BorgBackup: encrypted, deduplicated, compressed. This page describes the setup and how to restore from it. It is public, so it never contains the encryption passphrase or any key material — those live on the servers only (see Keys below).

What is backed up, and where it goes

Each host backs up the same five trees — /etc, /home, /var, /opt and /root — to a Borg repository on another machine, so a dead disk on one host does not take its backup with it. The configuration lives in /etc/borgmatic/config.yaml on each host and runs daily from the borgmatic.timer systemd timer (OnCalendar=daily, up to 3 h random delay).

HostRepositoryLast backupTookArchive sizeWhat is backed up (largest first)Notes
.4 (mini-4)—never
⚠️ no readable borgmatic config
———borg installed, no borgmatic configured yet
.6 (debian-6).21 — /mnt/WD9T/Backups/debian-6never
⚠️ Connection closed by remote host. Is borg working on the server?
——/var 16.2 GB
/home 2.1 GB
/etc <100 MB
/opt <100 MB
/root n/a
.7 (debian-7).21 — /mnt/WD9T/Backups/debian-7never
⚠️ Connection closed by remote host. Is borg working on the server?
——/var 8.7 GB
/opt 3.1 GB
/home 410 MB
/etc <100 MB
/root n/a
Healthchecks ping on success/failure
.8 (debian8).21 — /mnt/WD9T/Backups/debian8never
⚠️ Connection closed by remote host. Is borg working on the server?
——/home 143.8 GB
/etc 2.0 GB
/var 1.4 GB
/opt 102 MB
/root n/a
Healthchecks ping on success/failure
.15 (debian-15).21 — /mnt/WD9T/Backups/debian-15never
⚠️ Connection closed by remote host. Is borg working on the server?
——/home 4.9 GB
/var 2.4 GB
/etc <100 MB
/opt <100 MB
/root n/a
.21 (dell-r630-2x)/mnt/WD9T/Backups/dell-r630-2xnever
⚠️ Repository /mnt/WD9T/Backups/dell-r630-2x does not exist.
——/home 73.5 GB
/var 22.6 GB
/etc <100 MB
/opt <100 MB
/root n/a
.21 holds Nextcloud and all the other repos, so its own repo lives on .15 instead of on its own disk
.43 (r630-4x).21 — /mnt/WD9T/Backups/r630-4xnever
⚠️ Connection closed by remote host. Is borg working on the server?
——/home 69.0 GB
/var 6.9 GB
/etc <100 MB
/opt <100 MB
/root n/a
MariaDB is dumped first (borgmatic hook), so the database restore is consistent — a live copy of /var/lib/mysql alone would not be

Live data from the last collection (refreshes every 15 minutes). Archive size is the uncompressed size of what the latest archive holds; the source sizes are the live folders on each host, largest first — they explain where the archive's size comes from. A source shown as "n/a" could not be measured without root (e.g. /root).

Retention is the same everywhere: hourly 24, daily 7, weekly 4, monthly 12. Compression is lz4. Backups reach the repository over SSH as the avidys user, with a dedicated per-host key (~/.ssh/borg_backup).

Second copy

All repositories live on .21's USB disk (/mnt/WD9T, 9.1 TB), so a second copy is synced to the NAS every day at 12:00 by /home/avidys/mirror-backups.sh on .21 (user cron, no root needed). It mirrors /mnt/WD9T/Backups/ to //192.168.68.5/public/Avidys-Backups/ and pulls .21's own repo from .15 as well, so the NAS ends up with a copy of every repo. The run is logged to /home/avidys/mirror-backups.log on .21. The NAS is the second copy, not a third location: every copy is still on the local network.

How to check it is working

systemctl status borgmatic.timer          # timer enabled and counting down
systemctl status borgmatic.service        # last run result
journalctl -u borgmatic.service           # what the last runs did
borgmatic list                            # archives in this host's repo (as root)

If a backup stops, the first things to check are the timer (is it enabled?), disk space on the repository host, and SSH from the host to its repository machine. .8 and .7 also ping Healthchecks.io on success and failure, so a missed run shows up there.

Restore a file or a directory

On the host the file belongs to, as root:

borgmatic list                            # pick the archive (named by date)
borgmatic extract --archive <name> --path etc/nginx/nginx.conf
# extracts to the current directory; add --destination /tmp/restore to put it elsewhere

To restore a whole directory, give its path instead of a file. To see what an archive contains without extracting it: borgmatic list --archive <name>. Extraction never touches the live files unless you extract over them, so restoring to /tmp/restore first and comparing is the safe default.

Rebuild a machine from scratch

For a dead disk or a fresh install:

1. Reinstall Debian (or Ubuntu, for .21) and create the avidys user.
2. Install borgmatic:  sudo apt install borgmatic
3. Copy /etc/borgmatic/config.yaml from another host (or from the NAS copy
   of the docs) and put the passphrase back in — it is stored in the same
   file on every other host.
4. Authorize this host's borg key on the repository machine (append
   ~/.ssh/borg_backup.pub to its ~/.ssh/authorized_keys).
5. Restore the system trees:  borgmatic extract --archive <latest>
   (extract /etc and /home, then /var and /opt as needed).
6. Reinstall the services that were running (see the Services section on the
   servers page), restore the MariaDB dump on .43, then start them.
7. Run a fresh backup to confirm the new machine is covered again.

Test restores are the only proof a backup works: restore a single file to /tmp after any change to this setup, and redo a full restore test whenever a host is rebuilt.

Keys

The encryption passphrase is the same for all six repositories and is stored in /etc/borgmatic/config.yaml on each host — never on this page. Each host also keeps an export of its repository key in ~/.ssh/borg.key (created with borg key export). Lose both the passphrase and the key export and the repository cannot be opened. The SSH keys used to reach the repositories are per-host (~/.ssh/borg_backup) and are authorized only on the machine holding that host's repository.

Known limits

← Back to Avidys