Every database administrator dreads the same phone call: a table was dropped, a bad migration overwrote production data, or a script deleted rows that should never have been deleted. Automated backups help, but they only restore you to the moment the last backup ran, which may be hours before the incident. That gap is exactly what cloud sql point in time recovery closes. When point-in-time recovery is enabled, Cloud SQL keeps the transaction logs alongside your automated backups, so you can restore your database to any second within the retention window, not just to the last backup.
In this guide you will learn how cloud sql point in time recovery works on Google Cloud, how to enable it, how to restore a MySQL instance to a specific moment with both the console and the gcloud CLI, and how to verify the restored data before you put it back into service. You will also learn the retention limits, the clone-versus-restore behavior, and the errors that most often block a recovery.

How Cloud SQL Point in Time Recovery Works
Point-in-time recovery, usually shortened to PITR, combines two ingredients. The first is an automated backup, which gives you a full snapshot of the instance at a known time. The second is the binary log, or binlog, which records every change made after that snapshot. To restore to a chosen moment, Cloud SQL starts from the most recent backup before that moment and replays the binary log forward until it reaches the target time. The result is a database that reflects the state of your data at that exact second.
This mechanism explains both the power and the limits of PITR. You can only restore to moments that fall inside the binary log retention window, and you can only restore to moments after PITR was enabled, because no logs exist from before that point. It also explains why PITR is a safety net for logical errors, such as accidental deletes, rather than a replacement for backups: if the instance itself is destroyed and its logs are gone, only the automated backups remain.
Prerequisites for Cloud SQL Point in Time Recovery
Before you enable PITR, confirm that your instance runs a supported database engine and version, that automated backups are enabled, and that you have a user with the Cloud SQL Admin role or equivalent IAM permissions. PITR requires automated backups to be turned on, because the binary logs are stored alongside them. Also check that the instance has enough storage: binary logs consume disk space, and a busy instance can generate a significant volume of logs during the retention window.
gcloud sql instances describe my-instance --format="value(settings.backupConfiguration.enabled)"
gcloud sql instances describe my-instance --format="value(settings.backupConfiguration.pointInTimeRecoveryEnabled)"
If either command returns False, PITR is not ready yet. Enable automated backups first, then enable point-in-time recovery, and wait for at least one automated backup to complete before you rely on the feature. Until that first backup finishes, there is no base snapshot for the logs to replay from.
Enable Cloud SQL Point in Time Recovery
You can enable PITR from the Google Cloud console by opening the instance, choosing Edit, and turning on both automated backups and point-in-time recovery under the backup settings. The gcloud equivalent is a single patch command. Note that enabling PITR requires a brief configuration change on the instance, so apply it during a maintenance window if your workload is sensitive to restarts.
gcloud sql instances patch my-instance --backup --enable-bin-log --retained-backups-count 7
For MySQL instances, enabling binary logs is the step that activates point-in-time recovery. The retained backups count controls how many automated backups are kept, while the binary log retention period, seven days by default, controls how far back in time you can restore. You can adjust log retention with the --retained-transaction-log-days flag, up to the supported maximum for your edition.
Create an On-Demand Backup Before a Risky Change
PITR is a safety net, not an excuse to skip backups before risky operations. Before a major migration, create an on-demand backup so you always have a clean, named restore point regardless of the log window. This takes one command and gives you a fallback that does not depend on binary log replay.
gcloud sql backups create --instance=my-instance --description="pre-migration backup"
List your backups afterwards to confirm the new backup exists and to note its timestamp. If the migration goes wrong, you can restore from this backup directly, or use PITR to restore to a moment just before the migration started, whichever is more precise for your situation.
gcloud sql backups list --instance=my-instance --limit=10
Restore to a Point in Time with Cloud SQL Point in Time Recovery
Here is the behavior that surprises most people: a point-in-time restore does not overwrite your existing instance. Instead, Cloud SQL creates a new instance, a clone, containing the data as of the target time. Your original instance keeps running untouched. This is a deliberate safety design, because it means a failed or mistaken restore never destroys the data you are trying to recover.
The gcloud command for a point-in-time clone takes the source instance, a name for the new instance, and the target timestamp in RFC 3339 format. Use UTC timestamps to avoid timezone confusion, and pick a target time a minute or two before the incident, not exactly at it, to make sure the damaging transaction is excluded.
gcloud sql instances clone my-instance my-instance-restored --point-in-time="2026-10-31T08:14:00Z"
In the console, the same operation is available from the instance overview page under Restore, where you choose the point-in-time option and enter the date and time. The clone operation takes time proportional to the size of the database, because Cloud SQL must restore the backup and replay the logs. For large instances, plan for this duration and do not treat the restore as instant.
Verify the Restored Data Before Switching Over
Never point your application at the restored instance until you have verified the data. Connect to the clone with the MySQL client and check the specific tables and rows that were affected by the incident. Compare row counts against your expectations, and check the most recent timestamps in the restored data to confirm the restore landed at the intended moment.
mysql -h 10.20.30.40 -u appuser -p -e "SELECT COUNT(*) FROM orders WHERE created_at > '2026-10-31 08:00:00';"
mysql -h 10.20.30.40 -u appuser -p -e "SELECT MAX(updated_at) FROM orders;"
Once verification passes, you have two options. You can update your application configuration to point at the new instance, or you can export the recovered tables from the clone and import them into the original instance. The second option is usually safer when only a few tables were damaged, because it leaves the rest of the original instance untouched. When the clone is no longer needed, delete it to stop paying for a second instance.
Transaction Log Retention and Limits
Binary log retention defaults to seven days on Cloud SQL, which means you can restore to any moment within the last seven days, provided PITR was enabled for that whole period. Extending retention gives you a longer recovery window but consumes more storage, so weigh the cost against the risk. Very old incidents cannot be recovered with PITR at all; for those, only your retained automated backups or exported dumps help.
There are a few more limits worth knowing. PITR is not available on instances with automated backups disabled, and it does not cover every engine in the same way, so check the documentation for your specific engine and edition. Disk size also matters: the restored clone needs at least as much storage as the source instance, and a restore fails if the target disk is too small. If you are setting up Cloud SQL for the first time, our guide to setting up Cloud SQL for MySQL on Google Cloud walks through the initial configuration. For the equivalent AWS feature, see Amazon RDS automated backups and PITR. The official reference is the Google Cloud PITR documentation.
Troubleshooting Cloud SQL Point in Time Recovery
PITR is not enabled. The clone command fails or the console hides the point-in-time option. Enable automated backups and binary logging, then wait for the next automated backup to complete. PITR cannot restore to any moment before it was enabled.
Target time is outside retention. The binary logs for that moment have already been purged. Choose a more recent target time, or fall back to the nearest automated backup. If this happens often, increase the transaction log retention period.
Restore fails with a disk size error. The clone needs storage at least equal to the source instance. Increase the disk size on the target or confirm the source instance is not already near its storage limit.
Permission denied. The user running the restore needs Cloud SQL Admin or a custom role with clone and restore permissions. Check IAM bindings on the project, and remember that creating a new instance also requires compute and networking permissions in the project.
Restored data looks wrong. The target timestamp may be off by a few minutes, or the damaging transaction may have committed earlier than you assumed. Restore a second clone to an earlier timestamp and compare. Because restores create new instances, experimenting with timestamps costs nothing but time and temporary storage.
Conclusion
Cloud sql point in time recovery turns a scary incident into a manageable one. Enable automated backups and binary logging before you need them, keep an eye on log retention and disk usage, create an on-demand backup before risky changes, and remember that every restore produces a new clone you must verify before use. With those habits in place, a dropped table or a bad migration becomes a restore operation, not a data-loss event.