Data and Recovery · Chapter 3 of 3 · 2 min

The Restore Drill

A backup is only a hope until it has been restored. A safe, repeatable drill that restores into a separate database and never touches production.

Why drill

Backups fail quietly. A schedule stops after a permission change. A restore takes far longer than expected. The data comes back in a shape the app cannot read. You find out during an outage, which is the worst time. A drill finds out on a quiet afternoon.

The golden rule: never restore over production

Restore into a new, separate database, look at it, then delete it. Production is never touched. If a real recovery is needed, you copy the specific documents you need from the restored database, rather than replacing everything.

The drill, step by step

1. Note the time and pick a backup.

gcloud firestore backups list --project=PROJECT_ID

2. Restore it into a new database.

gcloud firestore databases restore --project=PROJECT_ID \
  --source-backup=projects/PROJECT_ID/locations/LOCATION/backups/BACKUP_ID \
  --destination-database=restore-drill

3. Time it. Write down how long the restore took. That is your real recovery time for a full database, not a guess.

4. Check the data. Pick a few things you know:

A quick script that counts documents in each collection, run against both databases, makes this repeatable.

5. Try point-in-time recovery too. Choose a minute from yesterday and export the database as it was then, into a private bucket. Confirm that a document you changed since then shows its old value.

6. Clean up.

gcloud firestore databases delete --database=restore-drill --project=PROJECT_ID

Delete only the drill database, and read the database name twice before pressing Enter.

7. Write it down. Date, backup used, time taken, what was checked, anything surprising. Next quarter's drill starts from this note.

Recovering from a real mistake

Most real data problems are small: a bad script changed some documents, a bug wrote wrong values for an hour. The drill gives you the method:

  1. stop the cause first (roll back the code, stop the script);
  2. find the last good moment;
  3. restore or export from that moment into a separate place;
  4. copy back only the affected documents, with a script that dry-runs by default and shows exactly what it would change;
  5. check, then write down what happened.

Make the drill part of the calendar

A recurring task, once a quarter, with this chapter linked. It takes under an hour once you have done it twice, and it is the only proof that the backups work.

Try it yourself

If you have backups but have never restored one, do step 2 into a separate database this week. If the command fails, or takes much longer than you assumed, you have just learned the most useful thing about your backup setup.