Dev and test Cloud SQL instances retaining more than 7 automated backups
What does ZopNight detect here?
Cloud SQL keeps 7 automated backups by default on Enterprise edition, and every extra backup adds billed backup storage. ZopNight flags dev, test, QA, staging and sandbox instances retaining more than 7, and prices the saving from the chargeable backup bytes that trimming retention back to 7 would remove, at Cloud SQL's backup storage rate.
Signal and threshold
| Field | Value |
|---|---|
| Rule IDs | RC-147 |
| Category | rightsizing |
| Severity | low |
| Metric | none — pure configuration read |
| Threshold | retained backups > 7 on a dev/test instance |
| Source | ZopNight |
| Permissions used | cloudsql.instances.list · cloudsql.instances.get · cloudsql.backupRuns.list |
Where it applies
Every retained backup adds to the storage line
Cloud SQL bills backups by the gigabyte: the pricing page lists “Backups (used)” as its own storage item, separate from the instance’s SSD or HDD capacity. Backups are incremental. Google’s backup overview explains that the oldest backup is roughly the size of the database and later ones hold only changes, so a busy dev database that retains many backups carries many days of churn.
The default is modest. The gcloud reference sets --retained-backups-count to 7 for Enterprise
edition and 15 for Enterprise Plus, with a valid range of 1 to 365. Development databases
configured by copying a production template often inherit a much longer setting.
Seeing retention per instance
gcloud sql instances list \ --format="table(name,settings.backupConfiguration.backupRetentionSettings.retainedBackups)"gcloud sql backups list --instance=INSTANCE_NAMEWhat makes a Cloud SQL instance a candidate
Production is ruled out first: a production-looking name or env=prod style label ends the
check. Then ZopNight needs positive dev or test evidence, from a name containing dev, test,
qa, staging, sandbox or demo or an environment label. Finally the instance must retain more than 7
backups.
Instances with no finding
The saving is priced from measured data, so ZopNight also needs the instance’s chargeable backup bytes and a Cloud SQL backup storage rate for its region. Without either, it stays silent rather than guessing. Production retention is a policy decision this rule does not second-guess.
Backup bytes above the 7-backup line
removed fraction = (retained backups - 7) / retained backupssaving = removed fraction x chargeable backup GiB x backup rate per GiB-hour x 730, capped at the instance's costThe rate is the dedicated backup storage rate, not the data disk rate, which is higher.
Trimming retention on a dev database
- Confirm no test plan depends on restoring from a backup older than a week.
- Set the count back to the default:
gcloud sql instances patch INSTANCE_NAME --retained-backups-count=7. - Leave point-in-time recovery settings as they are unless you mean to change them; transaction log retention is a separate setting.
- For data you must keep longer, take an on-demand backup, which is kept until you delete it.