I’ve used Google Cloud for a long time now, and using it often has made me mighty fond of Google’s gcloud command line API. It lets me backup my 200 instances I look over.
If you want to back up GCE instances, all you need is a windows or linux machine, either in cloud or outside, with gcloud sdk installed.
I won’t go over installing it yet, as there are plenty of writeups around, including on Google’s own documentation, that covers all operating systems. Being a 100% linux user, I’m not very windowsey. This writeup is written with a linux user in mind, but feel free to ask any question if you have any, I’ll try to help!
I’ll explain things as I go.
To backup GCE instances:
backing up google instances is super easy!
I’m in this for business, and I want to make sure my customers data is safe, I keep 30 daily backups (30 days of daily), 2 months of weekly backups, and 6 months of weekly backups of all my machines.
The cleanup script
My cleanups are manual, but this could be scripted
when I clean up I specify the date I want to delete:
example: ./vm_snapshot_deleter.sh 2018-02 2018-01 2017-12
would delete all machine snapshots, with the date string included.
This could be scripted just doing some date math. I’ll update this post if I feel froggy.
Backups SQL servers (Hosted mysql)
Google makes and auto deletes about 5-6 backups of hosted SQL, which didnt really work for us, as we like keeping longer retention times for our data.
The following script will allow you to back up 3 instances,
databasedb3, and will not auto delete. The delete script will follow: