cloudsql/BP/2026_003
Cloud SQL instance has Point-in-Time Recovery (PITR) enabled
Product: CloudSQL
Rule class: Best practice, opinionated recommendation
Description
Point-in-Time Recovery (PITR) enables the restoration of a Cloud SQL instance to a specific point in time, providing protection against accidental data loss or corruption. This rule checks if PITR is enabled.
Remediation
To enable Point-in-Time Recovery (PITR), automated backups must be enabled first.
[!WARNING] Enabling PITR on an existing instance will cause the instance to restart.
Use the following gcloud commands to enable PITR:
For PostgreSQL instances
gcloud sql instances patch INSTANCE_NAME \
--enable-point-in-time-recovery \
--retained-transaction-log-days=DAYS
Replace INSTANCE_NAME with your instance name and DAYS with the number of days to retain transaction logs (typically 1-7).
For MySQL instances
gcloud sql instances patch INSTANCE_NAME \
--enable-bin-log \
--enable-point-in-time-recovery \
--retained-transaction-log-days=DAYS