Using Google Cloud Scheduler, Cloud Functions, Pub/Sub, Cloud Storage, and Cloud IAM

Many — if not most — businesses store an off-site backup of critical client information that can really save them if something goes wrong. Simply backing up data and having an effective backup and disaster recovery plan in place can help mitigate various types of threats.

Cloud providers like Amazon or Google offer automated backup features for AWS RDS and Cloud SQL, respectively.

Let’s suppose we have the requirement to ensure up to 35 days of backups for Google Cloud SQL instances.

How Can We Achieve This for Google Cloud SQL?

Starting from the fact that Cloud SQL provides a REST API for administering its instances programmatically, we can build our solution on top of that API. As the official Google documentation states:

“The REST API is defined by BackupRuns, Databases, Instances, Flags, Operations, SslCerts, Tiers, and Users resources. Each resource supports methods for accessing and working with it. For example, the Instances resource supports methods such as get, insert, and list. For details of all the resources and their methods, see the Cloud SQL Admin API.”

We can schedule these API calls by using Cloud Scheduler, which will run daily. It will publish an empty message to a Pub/Sub topic and a Cloud Function will receive that message and trigger the Cloud SQL Admin API:

Image for post

#database #google-cloud-functions #cloud

How to Automate Google Cloud SQL Backups
13.60 GEEK