Stay organized with collectionsSave and categorize content based on your preferences.
Relevant to Cloud Firestore Standard edition and Cloud Firestore Enterprise edition.
Point-in-time recovery (PITR) protects against
accidental deletion or writes. PITR maintains versions of your
documents from past timestamps. For example, in the case of a developer
pushing any incorrect data, accidental deletes or writes, PITR can recover the
data to a point in time in the past (up to a maximum of 7 days).
For any live database that followsBest practices, use
of PITR doesn't affect the performance of reads or writes.
PITR window
After you enable PITR,Cloud Firestorestarts retaining PITR data. PITR data
is 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 read
documents at minute granularity using a whole minute timestamp. Reads that are
not at minute granularity like2023-05-30 09:00:00.1234AMreturn an
error that theread_timeis too old.
Only one version of a document is retained in case of multiple writes. For
example, if a document had multiple writes ranging fromv1, v2, ... vkbetween2023-05-30 09:00:00AM(exclusive) and2023-05-30 09:01:00AM(inclusive)
timestamp, a read request at timestamp2023-05-30 09:01:00AMreturns thevkversion of the document.
You can read from the data created during the PITR
window. The data is stored at a minute granularity and you can recover data
at the same granularity. The PITR feature is disabled by default.
TheearliestVersionTimefield of your database specifies the
earliest 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 in
the past,
and then write the results back into the live database. This is
typically used for surgical operations on a live database. For example, if
you accidentally delete a particular document or incorrectly update a
subset 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.
Exportthe database and specify
a timestamp in the past and then import it to a new database. The PITR
export operation supports all filters, including export of all documents and
export of specific collections.
You can clone or export PITR data where the timestamp
is a whole minute timestamp within the past seven days, but not earlier than
theearliestVersionTime.
Pricing
Consider the following pricing information before you enable PITR for your database:
Storage: Cloud Firestore with MongoDB compatibility measures the database size daily. Over the
period of a month, these sample points are averaged to calculate the
database storage size. This average value is multiplied by the unit price of
PITR (GB-month). Seestorage pricingfor 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 costs
based on the number of documents read. Seepricingfor more
information.
Minimum billing: You may be charged up to 1 day of PITR storage cost even if you disable PITR within a day after enablement.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["\u003cbr /\u003e\n\n\n|----------------------------------------------------------------------------------------|\n| *Relevant to Cloud Firestore Standard edition and Cloud Firestore Enterprise edition.* |\n\n\u003cbr /\u003e\n\nPoint-in-time recovery (PITR) protects against\naccidental deletion or writes. PITR maintains versions of your\ndocuments from past timestamps. For example, in the case of a developer\npushing any incorrect data, accidental deletes or writes, PITR can recover the\ndata to a point in time in the past (up to a maximum of 7 days).\nFor any live database that follows [Best practices](./best-practices), use of PITR doesn't affect the performance of reads or writes.\n\nPITR window\n\nAfter you enable PITR, Cloud Firestore starts retaining PITR data. PITR data\nis retained for 7 days in the PITR window.\n\nYou can read data for a timestamp based on when PITR was enabled:\n\n| PITR enablement status | Earliest PITR data available | |\n|------------------------------|----------------------------------------|---|\n| Disabled | 1 hour before the time of read request | |\n| enabled within 7 days | 1 hour before PITR was enabled | |\n| enabled more than 7 days ago | 7 days before the time of read request | |\n\n| **Note:** You can't start reading from 7 days in the past immediately after you enable PITR.\n\nA single version per minute is retained in the PITR window. You can read\ndocuments at minute granularity using a whole minute timestamp. Reads that are\nnot at minute granularity like `2023-05-30 09:00:00.1234AM` return an\nerror that the `read_time` is too old.\n\nOnly one version of a document is retained in case of multiple writes. For\nexample, if a document had multiple writes ranging from `v1, v2, ... vk` between\n`2023-05-30 09:00:00AM` (exclusive) and `2023-05-30 09:01:00AM` (inclusive)\ntimestamp, a read request at timestamp `2023-05-30 09:01:00AM` returns the `vk`\nversion of the document.\n\nYou can read from the data created during the PITR\nwindow. The data is stored at a minute granularity and you can recover data\nat the same granularity. The PITR feature is disabled by default.\n\nThe [`earliestVersionTime`](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases#Database) field of your database specifies the\nearliest permissible read time for your data.\n\nRegardless 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 the `earliestVersionTime`.\n\nWays to recover data\n\nThere are several ways to recover data:\n\n- To **recover a portion of the database** ,\n\n perform a [stale read](/docs/firestore/enterprise/understand-reads-writes-scale#stale_reads)\n specifying a query-condition or using direct key lookup along with a timestamp in\n the past,\n\n and then write the results back into the live database. This is\n typically used for surgical operations on a live database. For example, if\n you accidentally delete a particular document or incorrectly update a\n subset of data, you can recover it with this method. For instructions, see\n [recovering a portion of your database](/docs/firestore/enterprise/use-pitr#read-pitr).\n\n- To **recover the entire database**, use one of the following options:\n\n -\n [Clone the database](/docs/firestore/enterprise/create-databases#clone-database)\n\n to create a copy of the database at a specific timestamp.\n\n - [Export](/docs/firestore/enterprise/use-pitr#export-import) the database and specify\n a timestamp in the past and then import it to a new database. The PITR\n export operation supports all filters, including export of all documents and\n export of specific collections.\n\n You can clone or export PITR data where the timestamp\n is a whole minute timestamp within the past seven days, but not earlier than\n the `earliestVersionTime`.\n\nPricing\n\nConsider the following pricing information before you enable PITR for your database:\n\n- Storage: Cloud Firestore with MongoDB compatibility measures the database size daily. Over the\n period of a month, these sample points are averaged to calculate the\n database storage size. This average value is multiplied by the unit price of\n PITR (GB-month). See [storage pricing](https://cloud.google.com/firestore/enterprise/pricing) for more information.\n\n PITR storage doesn't have a free tier and you must have billing enabled if you want to use PITR.\n- Compute billing: Any queries that you make during the PITR window of 7 days,\n either through stale reads or exports, incur read operation costs\n based on the number of documents read. See [pricing](https://cloud.google.com/firestore/enterprise/pricing) for more\n information.\n\n- Minimum billing: You may be charged up to 1 day of PITR storage cost even if you disable PITR within a day after enablement.\n\nWhat's next\n\n- Learn more about how to [recover data with PITR](./use-pitr)."]]