lacework-global-273
Configure Cloud SQL Database Instances With Automated Backups (Automated)
Profile Applicability
• Level 1
Description
Best practices recommend having all SQL database instances set to enable automated backups.
Rationale
Backups provide a way to restore a Cloud SQL instance to recover lost data or recover from a problem with that instance. Automated backups need to be set for any instance that contains data that should be protected from loss or damage. This recommendation is applicable for SQL Server, PostgreSql, MySql generation 1 and MySql generation 2 instances.
Impact
Automated Backups will increase required size of storage and costs associated with it.
Audit
From Console:
- Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.
- Click the instance name to open its instance details page.
- Go to the
Backups
menu. - Ensure that
Automated backups
is set toEnabled
andBackup time
is mentioned.
From Command Line:
- List all Cloud SQL database instances using the following command:
gcloud sql instances list
- Ensure that the below command returns
True
for every Cloud SQL database instance.
gcloud sql instances describe <INSTANCE_NAME> --format="value('Enabled':settings.backupConfiguration.enabled)"
Remediation
From Console:
- Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.
- Select the instance for backup configuration.
- Click
Edit
. - In the
Backups
section, selectEnable automated backups
, and choose a backup window. - Click
Save
.
From Command Line:
- List all Cloud SQL database instances using the following command:
gcloud sql instances list
- Enable
Automated backups
for every Cloud SQL database instance using the below command:
gcloud sql instances patch <instance_name> --backup-start-time <[HH:MM]>
The backup-start-time
parameter is in 24-hour time, in the Coordinated Universal Time (UTC) time zone, and specifies the start of a 4-hour backup window. Backups can start any time during the backup window.
References
https://cloud.google.com/sql/docs/mysql/backup-recovery/backups
https://cloud.google.com/sql/docs/postgres/backup-recovery/backing-up