The 3-2-1 backup rule for servers, and how to test your restores

Backups fail in boring ways: nothing was copied, the copy was on the same disk, or nobody knew how to restore. The 3-2-1 rule and a restore test fix most of that.

Backups7 min readUpdated 26 Oct 2026

The 3-2-1 rule

Keep 3 copies of your data, on 2 different kinds of storage, with 1 copy off-site. For a server, that usually means: the live data, a local snapshot or dump, and an encrypted copy in separate storage that the server cannot delete.

What to back up

  • Databases, as consistent dumps rather than raw files
  • Site files and uploads
  • Configuration: web server, PHP, cron, firewall
  • Application secrets and encryption keys, stored separately and securely
  • Anything that is expensive to recreate by hand

Encrypt before it leaves the server

Encrypt with a public key on the server, and keep the private key somewhere else. If the server is compromised, the attacker cannot read old backups.

gpg --import backup-public.asc
mysqldump --single-transaction appdb | gzip | gpg --encrypt -r [email protected] > appdb-$(date +%F).sql.gz.gpg

A simple nightly job

A small script run from cron is enough to start. This example dumps, encrypts and ships with rclone, then writes a status file you can monitor:

#!/bin/bash
set -euo pipefail
D=$(date +%F)
mysqldump --single-transaction appdb | gzip | gpg --encrypt -r [email protected] > /var/backups/appdb-$D.sql.gz.gpg
rclone copy /var/backups/appdb-$D.sql.gz.gpg offsite:backups/
echo "{\"state\":\"ok\",\"date\":\"$D\"}" > /var/lib/backup-status.json
30 2 * * *  root  /usr/local/sbin/nightly-backup

Retention

Keep several generations. A common pattern is 14 daily copies, 8 weekly and 6 monthly, so you can recover from a problem you notice late. Make sure old copies are deleted automatically, or storage will quietly fill up.

Test the restore

Until you have restored a backup, you do not know it works. Do this at least every quarter:

  • Download the newest backup to a scratch machine
  • Decrypt it with the private key
  • Import the database into a scratch database
  • Compare table and row counts with production
  • Open the restored site and click through it
  • Write down how long it took

Alert on silence

A backup job that stops running makes no noise. Have it ping a monitor or write a status file that something checks, and alert when it is missing or old.

Questions

Are provider snapshots enough?

They are a good extra layer, but they live in the same account as the server. Keep an encrypted copy somewhere an attacker with your cloud login cannot reach.

How often should I back up?

Decide how much data you can afford to lose. Nightly is common. Busy shops may need database backups every few hours.

Want this done for you? See our Backups and recovery service: Encrypted off-server backups and a restore test, so you know they really work.

Want this done for you?

We set up and check all of this on client servers, with a backup first and a written record.