Skip to content
zefıly
← All posts

A backup you have not restored is not a backup: how to run a restore drill

5 min read

Backups fail quietly. An empty dump, a missing folder, a password nobody has. How to run a restore drill in an hour, what to check, what usually goes wrong, and how often to repeat it.

Almost everybody has backups. Far fewer people have ever restored one. The difference shows on the worst day: the job has reported "success" for a year, and the archive turns out to hold an empty database dump.

A restore drill is the only test that counts. It takes about an hour, and you find the problems while they are still cheap.

In short

  • Restore to a different place, never over the live site.
  • Restore everything the site needs: files, database, configuration, and the secrets to read the backup.
  • Open the restored site and use it. A file that exists is not a site that works.
  • Write down how long it took. That number is your real recovery time.
  • Repeat every few months, and after every change to the backup setup.

What a backup must contain

Before the drill, list what you would need on an empty server:

  • The site's files, including uploads.
  • A database dump, not a copy of the running database's data directory.
  • Configuration: .env, web server configuration, cron jobs, PHP settings.
  • The key to the backup itself. An encrypted backup whose password is stored only on the lost server is gone.
  • Where things are: DNS records, the provider account, certificates.

The last two are what people forget. Keep them in a password manager, outside the server.

The drill, step by step

1. Pick a place. A small temporary server at your provider, or a separate directory and database on a test machine. Not the production server's live paths.

2. Start from nothing. Use only what an outsider would have: the backup storage and your notes. If you need to copy "just one file" from the live server, you have found a gap.

3. Restore the files.

mkdir -p /restore/site
tar -xzf site-2026-11-12.tar.gz -C /restore/site

4. Restore the database into a new, empty database.

# MariaDB
mariadb -e "CREATE DATABASE restore_test"
gunzip -c db-2026-11-12.sql.gz | mariadb restore_test

# PostgreSQL
createdb restore_test
pg_restore --no-owner -d restore_test db-2026-11-12.dump

5. Check the content, not only the exit code.

# is the dump more than a header?
ls -lh db-2026-11-12.sql.gz

# are the tables there, and the newest rows?
mariadb restore_test -e "SELECT COUNT(*) FROM wp_posts; SELECT MAX(post_date) FROM wp_posts;"

Compare the counts with the live database. The newest date tells you how old the backup really is.

6. Start the site. Point the restored copy at the restored database, give it a temporary address, and open it. Log in. Open a page with images. Place a test order. Missing uploads and wrong file permissions show up here and nowhere else.

7. Measure and write down. How long from "start" to "site works"? What did you have to look up? Turn the answers into a short checklist that somebody else could follow.

8. Clean up. Delete the test server and the test database. They contain real customer data.

What usually goes wrong

  • The dump is empty or cut off. The dump command failed (wrong password, full disk) and the script compressed its error message. Look at the file size over time: a sudden drop is a warning.
  • The uploads are missing. The backup covers the code, which is in Git anyway, and skips the folder the users filled.
  • The backup is on the same disk. It disappears together with what it protects.
  • Nobody has the password. The encryption key lived in a file on the server.
  • The backup is too old. The job stopped months ago and nobody was told.
  • It takes far longer than assumed. Downloading 80 GB and importing a large database takes hours, not minutes.
  • Database copied as files. A copy of /var/lib/mysql or the PostgreSQL data directory taken while the server ran may not start.

Make dumps that restore

# MariaDB / MySQL: a consistent dump without locking InnoDB tables
mariadb-dump --single-transaction --routines --triggers mydb | gzip > mydb.sql.gz

# PostgreSQL: custom format, can be restored selectively
pg_dump -Fc mydb > mydb.dump

End the script with a check that fails loudly:

set -euo pipefail
test "$(stat -c%s mydb.sql.gz)" -gt 10000

pipefail matters. Without it, a failed dump piped into gzip still reports success.

How often?

  • A full drill every three to six months, and after every change to servers or backup tools.
  • An automatic check every day: did the backup run, is the size plausible, is the newest copy from today?
  • One file now and then: restore a single file somebody deleted. It keeps the procedure in your hands.

The 3-2-1 rule is still a good measure: three copies, on two kinds of storage, one of them somewhere else.

With Zefily

Zefily's backups use restic: site files and database dumps are encrypted on your server, deduplicated and sent to storage you own, such as S3-compatible storage, Google Drive or SFTP. A restore never writes over live files: it puts the snapshot into a restore folder, and you can browse a snapshot like a file manager and take single files. Because the repository and its password are yours, you can also restore with plain restic, without Zefily. See Backups and Backups you can restore without us.

Frequently asked questions

How do I test a backup?

Restore it to a separate place, import the database into a new empty database, start the site from the restored copy and use it. Compare row counts and the newest record with the live site.

How often should I test restoring backups?

A full restore drill every three to six months and after changes to the backup setup, with a daily automatic check that the backup ran and has a plausible size.

Why is my database backup empty?

Usually the dump command failed and the script did not notice. Use set -euo pipefail and check the file size at the end of the script.

Can I back up a database by copying its data directory?

Not while the server runs; the copy may be inconsistent and fail to start. Use mariadb-dump --single-transaction or pg_dump.

What is the 3-2-1 backup rule?

Three copies of the data, on two different kinds of storage, with one copy in another location.

See Databases for database copies in Zefily.

More posts

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →