Article

Keeping my files safe with Backup-Squirrel

A cute, cartoon squirrel with glasses holds an acorn next to a hollow tree in a rolling green landscape.

About 20 years ago I lost every photo from my first digital camera. There was no dramatic disk crash, just a stupid series of my own mistakes. The lesson stuck: always keep backups.

My tools changed a lot over the years: Carbon Copy Cloner and fully bootable clones, burned DVDs, rsync with hardlinks, my Synology NAS, CrashPlan, Backblaze, Arq, Time Machine. Somewhere along the way I heard about the 3-2-1 rule (which, I have to admit, feels a little antiquated ;)

  • 3 copies of your data
  • 2 different kinds of media (for example HDD and SSD)
  • 1 copy offsite

To me the core idea is simpler: have at least two backups, one onsite and one offsite, and preferably not made with the same tool.

Onsite: solved

Onsite it's Time Machine. Automatic, incremental backups that I can browse this nicely: I settled on that a long time ago.

Offsite: the real problem

My offsite backup has to be:

  • End-to-end encrypted
  • Cheap in transfer and storage, ideally deduplicated
  • Governed by a retention policy
  • Verifiable
  • Fully automatic and continuous
  • Immutable, at least for the crown jewels

Meeting restic

What I settled on years ago, both at work and at home, is restic. It ticks nearly every box above, except immutability, more on that below.

restic is written in Go. You back up into repositories that hold snapshots of your data. Deduplication works across snapshots and across files, and compression is built in. For my personal use case it's fast and efficient enough.

A cute, cartoon squirrel wearing glasses and a bow tie puts an acorn into a small teal safe filled with acorns.

I back up to a Hetzner Storage Box via SFTP. Those boxes are a real steal at around €2.59 per TB a month. restic also supports plenty of other backends, and the ones it doesn't support natively you can usually reach through its rclone integration.

restic alone can't make backups immutable; that's the storage side's job. The Storage Box takes automatic ZFS snapshots that are read-only over SFTP, so even a compromised Mac can't delete them.

Instead of boring you with all the details: restic's creator, Alexander Neumann, gave a great talk about it at FrOSCon 2015, A Solution to the Backup Inconvenience. And restic keeps getting better year after year: this summer's 0.19 learned to skip iCloud placeholders on macOS and loads its index much faster.

For the last four years I ran a backup script that looked roughly like this:

#!/bin/zsh
set -euo pipefail

# "storagebox" is a Host entry in ~/.ssh/config (Port 23)
export RESTIC_REPOSITORY="sftp:storagebox:/backups/$(hostname -s)"
export RESTIC_PASSWORD_COMMAND="security find-generic-password -s restic -w"

restic backup ~ --exclude-file ~/.restic-excludes
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12

if [[ $(date +%u) == 7 ]]; then  # Sundays
  restic prune
  restic check --read-data-subset "$(( $(date +%-V) % 12 + 1 ))/12"
fi

curl -fsS "$UPTIME_KUMA_PUSH_URL" > /dev/null

Restores? I've done enough of them in fire drills at work to trust restic with my own files.

Backup-Squirrel

Does the script work? Well, let's say it works just fine, and Uptime Kuma tells me when it fails. But even a battle-scarred kid who had nothing better than MS-DOS likes a GUI. I love the little menu bar icons of Arq, Time Machine and Backblaze that show when a backup is running.

Luckily restic can print JSON for most of its commands, which makes it a great base for your own tooling. And these days a SwiftUI Mac app is only a few /clarify sessions with Claude away (one of my public skills: it makes Claude interview me before it writes any code).

So meet my very own Backup-Squirrel. It does roughly what my script did, just a bit more configurable and with a squirrel in the menu bar.

A blue status bar containing icons for a steering wheel, a squirrel, a clock, a grid, and a toggle, plus the time 18:11.
There it is: the squirrel with its progress ring, busy backing up, right next to Time Machine.

Claude wrote most of the code, but it comes with tests, linting, CI and a pinned, checksum-verified restic binary. The squirrel is cute, not careless.

A macOS system settings window showing a backup progress bar for 'Home-Verzeichnis' at 43% completion.
A backup in progress. Sample data, and yes, the UI speaks German.

Would I recommend you use it? No. It's nowhere near feature complete, it only supports Hetzner Storage Boxes, and it has a few too many of my own defaults baked in.

What I learned

Building your own tooling around a solid core is an awesome idea. You get exactly what you need. It's not a lot of code, and it's cheap to build: it took me a Saturday morning, which is certainly cheaper than an Arq subscription.

But I would never vibe-code the core itself. I wouldn't trust a vibe-coded restic with my backups. Solid foundations aren't going anywhere, and building one still takes a lot of thought, expertise and good taste.

The code is on GitHub. No pull requests, but forks are very welcome.

  • self-hosting

Replies

To reply from the fediverse, follow @robert@rocu.de or look up the address of this post from your account.