Firetool

Home / Docs / Restore a deleted document

Docs

Restore a deleted Firestore document

Firestore has no recycle bin, so a deleted document is gone unless something kept it. Here are the four ways Firetool can bring one back, from the quickest to the one that needs a backup.

Finding a deleted document's copy and reading earlier times work in the Free edition. Putting a document back is a change, so it needs Pro.

Which way to use

How it was deletedUse
In Firetool, one document or a fewThe audit log's copy
In Firetool, by a bulk change, import, copy, move or migrationUndo the whole job
Outside Firetool (your app, a script, another tool), in the last hourRead it as it was
Outside Firetool, up to 7 days ago, with point-in-time recovery onRead it as it was
Anything olderA backup

From the audit log

Before Firetool deletes a document, it saves a copy in the audit log (unless the policy says to keep no copies).

  1. Open Tools, Audit log and find the delete. Search by the collection's path or the document ID.
  2. Click the entry. Entries with a saved copy are marked restorable.
  3. Choose Restore, then confirm. The document is written back as it was before the delete.

Restoring is a change itself: it follows your role and the project's rules and goes into the audit log.

Undo the whole job

When many documents went in one job, put them all back at once:

  1. Open Tools → Tasks and choose Undo… on the finished job. Or open any of the job's entries in Tools → Audit log and choose Undo this operation….
  2. Read the preview: documents put back (deleted or changed by the job), documents it created that are removed, and any that can't be undone. Nothing has changed yet.
  3. Choose Undo. Changes made to those documents after the job are replaced too, so look at the preview first.

More in Undo an operation.

Read it as it was

Firestore can read data as it was at an earlier time: the last hour on every database, and up to 7 days back when point-in-time recovery is turned on for it. This finds documents deleted by anything, not only Firetool.

  1. Open the collection the document was in.
  2. Choose Now in the query bar (Show as of…) and pick a time before the delete. The table shows the collection as it was then.
  3. Tick the document and choose Put these back… (also in Actions ▾ and the command palette).
  4. Choose Preview: it lists the document as not there now. Choose Put back.

Each document read at an earlier time is one Firestore read. To turn on point-in-time recovery for a database, open Firestore backups in the project's Services page (Pro).

From a backup

For anything older, you need a Firetool backup made before the delete.

  1. Right-click the database (or its project) and choose Restore a backup…, then pick the backup file.
  2. Choose Choose documents…, then paste the document's path (one a line), or tick its collection.
  3. Choose Preview…, then Preview, and Put back. Only documents that aren't there now, or differ, are written.

Details in Backup and restore. Google's own managed backups are restored to a new database from Firestore backups in the Services page.

Be ready next time

  • Keep Keep restorable copies of on Automatic (the default) in Tools, Policy and roles: on production, every change keeps a copy.
  • Turn on point-in-time recovery for production databases: 7 days of earlier times instead of one hour.
  • Back up regularly: backups from the app, or firetool backup run by your system's scheduler.
  • Mark production projects, so deletes ask for the project ID first: roles and production safety.

Questions

Does Firestore have a recycle bin or undo?

No. A deleted document is gone from Firestore. It can only come back from a copy: Firetool's audit log, an earlier time while Firestore still keeps it, or a backup.

Can I restore a document deleted in the Firebase console?

Yes, if it was deleted within the last hour, or within 7 days with point-in-time recovery on: read the collection as it was and put the document back. Otherwise you need a backup.

Are subcollections restored too?

Deleting a document doesn't delete its subcollections in Firestore, so they're usually still there. A backup restore of a collection path brings back everything under it.