Description
Cloud SQL replicas can copy accidental deletions or corrupted data. Keep a backup you can restore to a time before the change.
Potential impact
An old backup can leave a gap in recovered data. A slow restore can keep the service offline beyond its recovery target.
Remediation
- Set
backup_configuration.enabled = truein the instance settings. Choose a backup schedule and retention period that cover the history you need. Configure the engine’s point-in-time recovery settings if you need finer recovery points. - Limit backup and restore permissions. Monitor backup success and regularly time a test restore.
Examples
These are excerpts. Choose a supported PostgreSQL version and machine type for your deployment and supply the other required settings.
Before
hcl
resource "google_sql_database_instance" "db" {
name = "master-instance"
database_version = "POSTGRES_11"
region = "us-central1"
settings {
tier = "db-f1-micro"
backup_configuration {
enabled = false
}
}
}
After
hcl
resource "google_sql_database_instance" "db" {
name = "master-instance"
database_version = "POSTGRES_11"
region = "us-central1"
settings {
backup_configuration {
enabled = true
}
}
}
The examples change enabled from false to true. After applying the change, check the timestamp of the latest successful backup.