~/home

Restic to a second disk, the boring way

· backups

TL;DR: Run restic backups from a systemd service and timer (OnCalendar, RandomizedDelaySec, Persistent=true) with restic forget --prune retention, credentials in an EnvironmentFile, and a monthly test restore.

I tried a few backup tools with web UIs, then went back to restic and a systemd timer. The only backup that works is the one that runs without me.

Service

# /etc/systemd/system/restic-backup.service
[Unit]
Description=restic backup

[Service]
Type=oneshot
EnvironmentFile=/etc/restic/env
ExecStart=/usr/bin/restic backup /etc /home /srv --exclude-caches
ExecStartPost=/usr/bin/restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

/etc/restic/env holds RESTIC_REPOSITORY and RESTIC_PASSWORD_FILE. Make it chmod 600.

Timer

# /etc/systemd/system/restic-backup.timer
[Timer]
OnCalendar=*-*-* 03:30
RandomizedDelaySec=20m
Persistent=true

[Install]
WantedBy=timers.target

Persistent=true runs a missed backup at the next boot, which matters for a machine that is sometimes off at 3:30.

The part people skip

Once a month, restore one random file somewhere else and open it. restic check --read-data-subset=5% is good too, but it doesn't tell you whether you can find the file you actually need.