Point-in-time recovery (PITR) overview Stay organized with collections Save and categorize content based on your preferences.
Spanner point-in-time recovery (PITR) provides protection againstaccidental deletion or writes. For example, if an operator inadvertently writesdata or an application rollout corrupts the database, with PITR you can recoverthe data from a point-in-time in the past (up to a maximum of seven days)seamlessly. If you need longer-term retention of data, you can use eitherBackup and Restore orExport and Import.
By default, your database retains all versions of its data and schema for onehour. You can increase this time limit to as long as seven days through theversion_retention_periodoption. For instructions, seeSet the retention period.Spanner stores earlier versions of data at microsecond granularity and thedatabase maintains anearliest_version_time,which represents the earliest time in the past that you can recover earlier versionsof the data.
spanner.databases.drop permissionare set appropriately. For more information, seeUsing IAM securely.You can also enabledatabase deletion protectionto prevent the accidental deletions of databases.Ways to recover data
There are two ways to recover data:
Torecover a portion of the database, perform astale readspecifying a query-condition and timestamp in the past, and then write theresults back into the live database. This is typically used for surgicaloperations on a live database. For example, if you accidentally delete aparticular row or incorrectly update a subset of data, you can recover itwith this method. For instructions, seerecovering a portion of your database.
Torecover the entire database,backup orexport the database specifying a timestamp in thepast and then restore or import it to a new database. This is typically usedto recover from data corruption issues when you have to revert thedatabase to a point-in-time before the corruption occurred. Note thatbacking up or exporting a database could take several hours and that youcannot restore or import to an existing database. For instructions, seerecovering the entire database.
Performance considerations
Databases with longer retention periods and, in particular, those thatfrequently overwrite data, use more system resources. This can affect how yourdatabase performs, especially if your instance is not provisioned with enoughcompute capacity. If your database has a very high overwrite rate(for example, if your database is overwritten multiple times per day), you mightconsider increasing the retention period gradually andmonitoring the system.Here are some things to be aware of:
Increased storage utilization. We recommend setting upstorage alerts to ensure that youdon't exceed thestorage limit. When youincrease the retention period, keep in mind that storage usage will increasegradually as the database accumulates earlier versions of data. This is becausethe old data that would have expired under the previous retention period, is nolonger expired. So, for example, if you increase the retention period from 3days to 7 days, you need to wait for 4 days for database storage usage tostabilize. We also provide instructions forestimating the storage increase.
Increased CPU usage and latency. Spanner uses additional computingresources to compact and maintain earlier versions of data.Monitor your instance and databaseto ensure that latency and CPU utilization remain at acceptable levels.
Increased time to perform schema updates. An increased retention periodmeans thatschema versionsmust be retained for longer durations potentially causing schema updates to be
throttledwhilewaiting for server resources. Make sure that you are followingbest practices for schema updatesand staying within thelimits for schema updates.
Pricing
There is no additional charge for using PITR. However, if youincrease the version retention period of your database from the default one hour,your database storage and compute capacity costs might increase. Your on-demandbackup cost is unaffected because only a single versionof your database is stored. For more information, see thePerformanceconsiderations section. Before increasing a database's versionretention period, you canestimate the expected increase in database storage.
For general information about how Spanner is charged, seeSpanner pricing.
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-19 UTC.