Point-in-time recovery (PITR) overview Stay organized with collections Save and categorize content based on your preferences.
Point-in-time recovery (PITR) protects againstaccidental deletion or writes. PITR maintains versions of yourdocuments from past timestamps. For example, in the case of a developerpushing any incorrect data, accidental deletes or writes, PITR can recover thedata to a point in time in the past (up to a maximum of 7 days).
For any live database that followsBest practices, useof PITR doesn't affect the performance of reads or writes.PITR window
After you enable PITR,Cloud Firestore starts retaining PITR data. PITR datais retained for 7 days in the PITR window.
You can read data for a timestamp based on when PITR was enabled:
| PITR enablement status | Earliest PITR data available | |
|---|---|---|
| Disabled | 1 hour before the time of read request | |
| enabled within 7 days | 1 hour before PITR was enabled | |
| enabled more than 7 days ago | 7 days before the time of read request |
A single version per minute is retained in the PITR window. You can readdocuments at minute granularity using a whole minute timestamp. Reads that arenot at minute granularity like2023-05-30 09:00:00.1234AM return anerror that theread_time is too old.
Only one version of a document is retained in case of multiple writes. Forexample, if a document had multiple writes ranging fromv1, v2, ... vk between2023-05-30 09:00:00AM (exclusive) and2023-05-30 09:01:00AM (inclusive)timestamp, a read request at timestamp2023-05-30 09:01:00AM returns thevkversion of the document.
You can read from the data created during the PITRwindow. The data is stored at a minute granularity and you can recover dataat the same granularity. The PITR feature is disabled by default.
TheearliestVersionTime field of your database specifies theearliest permissible read time for your data.
Regardless of whether PITR is enabled or not, you can read (but not export) documents at any microsecond-granularity timestamp within the past hour, but not before theearliestVersionTime.
Ways to recover data
There are several ways to recover data:
Torecover a portion of the database,perform astale readspecifying a query-condition or using direct key lookup along with a timestamp inthe past,and then write the results back into the live database. This istypically used for surgical operations on a live database. For example, ifyou accidentally delete a particular document or incorrectly update asubset of data, you can recover it with this method. For instructions, seerecovering a portion of your database.
Torecover the entire database, use one of the following options:
Clone the databaseto create a copy of the database at a specific timestamp.
Export the database and specifya timestamp in the past and then import it to a new database. The PITRexport operation supports all filters, including export of all documents andexport of specific collections.
You can clone or export PITR data where the timestampis a whole minute timestamp within the past seven days, but not earlier thanthe
earliestVersionTime.
Pricing
Consider the following pricing information before you enable PITR for your database:
Storage:Cloud Firestore measures the database size daily. Over theperiod of a month, these sample points are averaged to calculate thedatabase storage size. This average value is multiplied by the unit price ofPITR (GB-month). Seestorage pricing for more information.
PITR storage doesn't have a free tier and you must have billing enabled if you want to use PITR.
Compute billing: Any queries that you make during the PITR window of 7 days,either through stale reads or exports, incur read operation costsbased on the number of documents read. Seepricing for moreinformation.
Minimum billing: You may be charged up to 1 day of PITR storage cost even if you disable PITR within a day after enablement.
What's next
- Learn more about how torecover data with PITR.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.