Backups that actually restore
For years I had what I thought was a sensible setup: photos on the laptop, a nightly copy to a USB drive, and a weekly sync to a remote box. Three copies, two kinds of media, one offsite. Textbook.
Then the laptop disk died, and I learned that the USB copy had silently stopped running in June because the drive's mount point changed after an OS update. The remote copy was fine, but it was a sync, not a backup, so it had faithfully mirrored a folder I had reorganised and half-deleted the week before.
What I changed
The fix was not more copies. It was making failures loud and making history cheap.
- Snapshots instead of syncs. I moved the remote copy to
restic, so a bad Tuesday does not overwrite a good Monday. - The job checks its own target. The nightly script refuses to run if the destination is not the drive it expects, and it says so.
- A monthly restore test. On the first of the month, a cron job restores a random folder into a temp directory and compares checksums.
#!/bin/sh
set -eu
target=/mnt/backup
[ "$(cat "$target/.volume-id" 2>/dev/null)" = "photos-usb-01" ] || {
echo "backup target missing or wrong drive" >&2
exit 1
}
restic -r "$target/repo" backup "$HOME/Pictures" --tag nightly
The volume-id file is a dumb trick, but it has already caught one mix-up where I plugged in the wrong drive.
The part I keep forgetting
A backup you have never restored is a hope, not a backup.
The restore test is the only piece that has ever told me something I did not already know. Everything else just makes me feel organised.