Data safety

Firestore point-in-time recovery without scripts

Browse the history of any document, compare past versions with the current one, and restore a single document or a whole set of query results to how they were minutes or days ago.

Quick answer

How do you restore a Firestore document to an earlier version?

Firestore keeps past versions of your documents through point-in-time recovery (PITR): the last hour on every database, and 7 days at one version per minute once you enable PITR. Natively, you read those versions with a server client library or the REST API at a chosen read time and write the data back yourself, or you clone the whole database at a timestamp.

Fuego puts the same history in a window: pick a moment, compare it with the current document, and restore one document or many in a few clicks.

7-day window

With PITR enabled, Firestore keeps past versions of your documents for 7 days. With PITR disabled, only the last hour is available.

One version per minute

If a document changes several times in one minute, only the last version of that minute is kept. Within the last hour any timestamp works; older read times must be whole minutes.

Off by default

You enable PITR per database, in the Google Cloud console under Disaster Recovery or with the gcloud --enable-pitr flag. History starts one hour before you enable it.

Billed storage

PITR storage has no free tier and needs billing enabled on the project. Reading past versions is billed as normal document reads.

Sources: Firestore documentation on point-in-time recovery and using PITR.

What Fuego adds

Point-in-time recovery features in Fuego

Fuego's PITR dialog for a Firestore document: a calendar to pick the read time, the window of available versions, and the past version compared with the current one
A document's history: pick a read time within the available window, then compare that version with the current one before restoring it.

Document history

Right-click a document and choose PITR to see its versions. Step through them with the arrows, or pick a date and time in the calendar.

Side-by-side comparison

Each past version opens next to the current document in a diff view that highlights added, removed and changed fields, so you see what a restore will change.

Restore in one click

Restore version writes the selected version back to the document once you confirm. No read times to compute, no script to write.

Read-time queries

Set a read time and the table shows a collection, or any query, as it was at that moment. From a document's history, Open collection at this date does the same in a new tab.

Load differences

Highlight the documents and fields that changed between the read time and now, right in the table, then open the diff of any row.

Bulk restore

Restore every result of a read-time query, or only the documents you select. Documents that did not exist at the read time are left untouched.

A read time is a setting of the query itself, so it combines with filters and sorting in the query builder. Restores of many documents run as background tasks, like the other bulk operations.

Workflow

How to restore Firestore data with Fuego

There are two ways: one document from its context menu, or many documents from a query at a read time.

Restore one document

  1. Find the document

    Open the collection in the database viewer and locate the document you want to restore.

  2. Open its history

    Right-click the document, or open its context menu, and choose PITR. A history panel shows the available versions.

  3. Compare versions

    Select a timestamp to view that version and compare it with the current document.

  4. Restore the version

    Click Restore version and confirm. The document reverts to the state it had at that moment.

Restore many documents with a read time

  1. Set a read time

    Open the collection or query and set its read time with the clock button in the toolbar. The table shows the documents as they existed at that moment.

  2. Review the changes

    Turn on Load differences to highlight what changed, and compare each document with its current version.

  3. Select documents

    Select the documents you want to bring back, or keep the whole result set.

  4. Restore and confirm

    Open Actions, choose Restore (PITR) for all results or only the selected documents, and confirm.

Both flows are covered step by step, with animations, in the Point in Time Recovery docs and in the PITR walkthrough on the blog.

Use cases

When point-in-time recovery helps

Undo a bad write

A script, a migration or a manual edit overwrote the wrong fields. Set a read time from just before it ran, load the differences and restore only what it touched.

Bring back deleted documents

A document deleted within the window still appears in a read-time query from before the deletion. Select it and restore it to the same path.

Find out what changed

Step through a document's versions to see when a field changed and what it held before, without restoring anything.

Rehearse on the emulator

Since Fuego 2.2, emulator projects support document history, restores and read-time queries, so you can practice a restore before you need one in production.

Good to know

Limits and things to know

In Firestore

  • Enable PITR before you need it. Without it you only have the last hour, and enabling it never recovers anything older than one hour before you did.
  • Seven days is the ceiling. For older data, keep regular copies: Firestore scheduled backups can be retained for up to 14 weeks and are restored into a new database, or you can export collections to JSON with Fuego.
  • Reading needs server code. Natively, past versions are read with the server client libraries (Go, Java, Node.js and PHP, inside a read-only transaction) or the REST API; the Android, iOS and Web SDKs are not supported.

In Fuego

  • A restore is a write. Fuego writes the past version over the live document. It never deletes documents that were created after the read time.
  • Emulator history starts with the emulator. Earlier versions, imported data included, are not available, and Open collection at this date is not offered there. See PITR on the emulator and Emulators.
  • Also in the terminal. fuego doc get <path> --at <time> prints a document as it was at a past moment. See the command line docs.
  • Plans. Point-in-time recovery is part of the Individual, Team and Lifetime Deal plans, not the Free plan. Compare them on the pricing page.

FAQ

Frequently asked questions

How long does Firestore keep point-in-time recovery data?

With PITR enabled, Firestore keeps one version per minute for 7 days; with PITR disabled, only the last hour. Right after you enable PITR, the earliest readable version is one hour before you enabled it, and the full 7-day window builds up over the following week.

Do I need to enable PITR before I can use it in Fuego?

Not for the last hour, which every Firestore database keeps. To go back further, enable PITR on the database under Disaster Recovery in the Google Cloud console, or with gcloud. When PITR is off, Fuego's read-time picker tells you and links to the database's Disaster Recovery settings in the Firebase console. PITR storage has no free tier, so billing must be enabled.

Can I restore a deleted Firestore document?

Yes, if it was deleted within the recovery window. Set a read time from before the deletion and the document appears in the results as it was then. Select it and restore it, and Fuego writes it back to the same path.

Can Fuego restore an entire Firestore database?

Fuego restores documents in place: one document, a selection, or all the results of a read-time query. To recreate a whole database as it was at a given minute, Firestore clones it into a new database with the gcloud firestore databases clone command.

Does point-in-time recovery work with the Firestore emulator?

Yes, since Fuego 2.2: document history, version comparison, restores and read-time queries all work on emulator projects. History starts when the emulator starts, and Open collection at this date is not offered there.

Which Fuego plans include point-in-time recovery?

Point-in-time recovery is included in the Individual, Team and Lifetime Deal plans, and in the Individual plan's 14-day free trial. The Free plan does not include it.

Get started

Recover Firestore data visually

Download Fuego, connect your project and open any document's history. Point-in-time recovery is included in the paid plans and in the 14-day free trial.