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.