Back to selected work

Server backups and recovery case study

IREE Solar's staff assistant, website chat and automation run on one small cloud server, and I look after it alone. A separate backup machine pulls an encrypted backup every night, upgrades run only on top of a fresh backup, and a monthly drill proves the backup restores: 6,141 MB in 92 seconds in 2026.

A problem I had to debug

Each night the backup should finish, and then the night's upgrades run on top of it. In 2026 the backup failed and saved nothing. Three checks alerted me within 40 minutes, and both upgrades refused to run without a backup, as designed.

The backup log named the step. The tar command that streams the server's files to the backup machine stopped on n8n's event log with "file changed as we read it". n8n appends to that log all the time, and tar exits with an error when a file changes while it reads it. The backup counts any error as a failure, which is right: a half-read file is not a good backup.

The harder question was why it failed now. Shared work documents had just moved onto the server. The backup grew from about 1.2 GB to 5.9 GB, and a run went from about 2 minutes to about 14. A longer read made a collision far more likely.

The event log isn't needed for a restore, so I left it out of the backup and deployed the change the same day. A manual backup then finished without errors. I wrote down the rule: leave out such logs rather than ignore tar's error, which would also hide a real read error.

The problem

Upgrades, deploys and growing data can all break something. I needed to know when something breaks, never upgrade without a fresh backup, and have proof that the backup restores.

Constraints

  • One server shared by 12 containers and CI jobs.
  • Watchdogs and backup copies stay off the server, so they work when it is down.
  • One person on call, so alerts must be few and clear.

What I built (design)

  • Containers with limits. Every container has a memory cap and runs without extra privileges.
  • Nightly backup, pulled from outside. Each night the backup machine pulls an archive stream into an encrypted restic repository. The server can only stream data out; it cannot read or change the repository. Databases are copied with SQLite's online backup API while the apps run. Each night also verifies a thirtieth of the stored data, so 30 nights cover all of it.
  • A fixed night order. Exports, backup, the backup machine's upgrade, the server's upgrade, a reboot only if needed, then security scans.
  • An upgrade gate. The server upgrade runs only in a short window after the backup, and only when tonight's backup succeeded, CI is idle and no other change is in progress. Otherwise it skips and alerts me.
  • One change at a time. Every deploy and live change takes one lock. A second change waits up to 60 seconds, then stops and says who holds the lock and why.
  • Restore points. Before a change, the old state is saved with a delete-after date.
  • Monitoring. Scheduled-job checks confirm each job ran and the server is alive. Uptime checks from outside the server run every minute, and a dashboard tracks CPU, memory and disk. Alerts reach my phone.

Where AI helped

I use AI coding agents (Claude Code, Codex and Grok) for much of the implementation. I set the rules, such as the night order and keeping watchdogs off the server, review each pull request and check the result on the machines myself.

How it is tested

  • Monthly restore drill. The backup machine restores the newest snapshot into a temporary folder, checks the key configuration files, runs an integrity check on the three databases, then deletes the folder.
  • Monthly alert test. A job fails its own check on purpose and waits for the phone alert. In 2026 the alert arrived 1 second after the failure.
  • Gate and lock. In 2026 the gate skipped a run outside its window. In 2026 a second deploy, blocked by the lock, stopped after 60 seconds with "Nothing was deployed".

What a person controls

  • I approved the night order and automatic upgrades in 2026. On the server, only security updates and a few core packages install by themselves. App images change through a reviewed update and the deploy script.
  • Major version updates wait for my decision.
  • A person deletes a restore point once the change is accepted.

Results

  • Postmortem 0001, 2026. After a deploy on a busy server, the chat server started too slowly for Docker's default health check, so the proxy in front of it never started. The sites answered errors for about 3 minutes, until I started the proxy by hand. The lasting fix, a 300-second start grace, was live 23 minutes after the errors began.
  • 2026: 6,141 MB and 3,997 files restored in 92 seconds, all three databases passing.

Limits and what's next

  • A backup run now takes 4 to 15 minutes, and the backup machine's upgrade waits a fixed time for it. If the shared documents keep growing, I'll raise that wait or start the backup earlier.
  • The drill proves files and databases restore; a full server rebuild follows a separate written procedure.

What I'd do differently

  • Give every slow-starting service a start grace from its first version. In postmortem 0001, one slow start held back the proxy and every site behind it.
  • Prove each job's failure alert from day one. Earlier in 2026 a failed backup step could still log "ok". Now the script checks each step.
  • Make scripts stop on an error they don't recognize. In postmortem 0001, my deploy script read a dropped cloud snapshot as a network blip and kept retrying, which pushed the deploy into a busier time. It now stops and says why.
  • Decide which live files a backup may skip at design time. Then check the next backup after adding a large data folder.

Sources: operations records, runbooks and postmortems, 2026.

Back to selected work