Description
Configure Cloud SQL backups on the source instance. A MySQL read replica cannot have its own backup policy, and high-availability replication can copy accidental changes.
Potential impact
If the last usable backup is too old, recent data may be lost. An untested restore can prolong an outage.
Remediation
For standard backups, set settings.backup_configuration.enabled to true. Choose the schedule and retention for your recovery window. If you need point-in-time recovery, configure the logs required by your engine. Check for a successful backup and test a restore.
Examples
These excerpts create MySQL instances. Supply supported mysql_database_version and cloud_sql_tier values, your project and a service account JSON file. The google.cloud 1.14.0 module cannot update an existing instance. Use a supported Cloud SQL administration tool for that change.
Before
- name: create a second instance
google.cloud.gcp_sql_instance:
name: "{{ resource_name }}-2"
database_version: "{{ mysql_database_version }}"
settings:
tier: "{{ cloud_sql_tier }}"
region: us-central1
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
- name: create a forth instance
google.cloud.gcp_sql_instance:
name: "{{ resource_name }}-2"
database_version: "{{ mysql_database_version }}"
settings:
backup_configuration:
binary_log_enabled: no
enabled: no
tier: "{{ cloud_sql_tier }}"
region: us-central1
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
Read the two tasks as separate examples. The first omits the backup policy, so check the applied settings. The second explicitly disables backups and binary logging.
After
- name: create a instance
google.cloud.gcp_sql_instance:
name: "{{ resource_name }}-2"
database_version: "{{ mysql_database_version }}"
settings:
backup_configuration:
binary_log_enabled: yes
enabled: yes
tier: "{{ cloud_sql_tier }}"
region: us-central1
project: test_project
auth_kind: serviceaccount
service_account_file: /tmp/auth.pem
state: present
The revised task enables backups and MySQL binary logging. Other database engines use different point-in-time recovery settings.