Point-in-time recovery (PITR) overview (original) (raw)

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 follows Best practices, use of PITR doesn't affect the performance of reads or writes.

PITR window

After you enable PITR, Firestore starts 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 like 2023-05-30 09:00:00.1234AM return an error that the read_time is too old.

Only one version of a document is retained in case of multiple writes. For example, if a document had multiple writes ranging from v1, v2, ... vk between2023-05-30 09:00:00AM (exclusive) and 2023-05-30 09:01:00AM (inclusive) timestamp, a read request at timestamp 2023-05-30 09:01:00AM returns the vkversion 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.

The earliestVersionTime field 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 the earliestVersionTime.

Ways to recover data

There are several ways to recover data:

Pricing

Consider the following pricing information before you enable PITR for your database:

What's next