Score:0

How does Google Cloud Platform handle database backups with --async flag?

za flag

I'm currently working on adding an extra step to our companies CI/CD pipeline so we make backups of the database before making a deployment that could potentially run migrations on our database.

To make the backup I authenticate with Google Cloud Platform using the command: gcloud auth activate-service-account --key-file /path/to/keyfile.json

After authenticating I use the command: gcloud sql backups create --async --instance instance_name

My question is about what the implications of adding the async flag are. I understand that doing so means my pipeline will not wait for the backup to be completed before moving on to the next step, however, if the next step involves running migrations that could potentially break something, does that mean that the backup I made in the previous step could end up in an in-between state where the migration has been partially ran?

How does Google actually handle backup creation? Do they make a snapshot of the database at that point in time and then make the backup from that? Would it be safer to remove the --async flag in order to ensure that the backup has been completed before running any potential migrations?

I've tried looking at the documentation but it doesn't really go into detail about this.

Score:0
us flag

I think that for the snapshot purpose, it is best not to use --async, unless you are really sure that your next operation in the CI/CD would not interfere with the snapshot operation.

That said, I think the snapshot would be completed but the next operation, if it has something to do with the cloudsql instance or databases, will fail if it is ran at the same time while the snapshot is running.

Just, as an exemple: you can not export multiple databases via gcloud sql export sql simulatneously. You have to wait for the first run to complete, else the second execution will fail!

Hope this help!

Score:0
jp flag

We can know the status of backup process using these commands:-

  1. Use the gcloud sql operations list command to get the operation ID.

  2. Use the gcloud sql operations describe command to get the operation's status. For more details see here

For --async command refer google doc. It looks like the execution will return to other jobs, and backup will go on in background.

za flag
I take it that means that creating a backup with the --async flag means there would be no guarantee that the backup would not end up with a partial migration implemented. Opted for just running the migration without the --async flag.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.