Backing up google cloud platform instances

Posted Leave a comment

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.

daily

weekly

monthly:

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, databasedb, databasedb2, databasedb3, and will not auto delete. The delete script will follow:

Trimming SQL backups

Downscaling 4K video with ffmpeg

Posted Leave a comment

Just about every camera I have records in 4K, I record in full quality, and down convert when needed:

single file:

bash script:

save this file to convert.sh and chmod +x convert.sh

usage:

the output files will have a filename of filename.mp4.1080P.mp4, but for my use it’s fine.

Migrate DNS from Dyn to Google Cloud

Posted Leave a comment

My day job had used Dynect Managed DNS for years, but as our queries per second increased to 30, we had a problem. At one time we used their traffic manager, but we no longer balanced at DNS level, which dropped the bill by quite a bit.

I’ve been hosting in Digital Ocean for years, and also have machines in Google Cloud, a very large buildout between them both. I did the math using the Google Cloud calculator, and realized Google’s DNS was way cheap for our access level so I took the plunge.

Log in to manage.dynect.net
under “manage dns” select your zone.
under zone the zone, find “zone reports” and click it
click “download” under zone file.

to create a zone within Google DNS:

to import your zone file:

‘pending’ here just means it sent the load info to google dns, and its processing it.

Now we need to test it, but first, we need our DNS servers:

Now we want to take note of the

lines, we can use dig with them to test the new server has your records loaded:

watch will loop the dig command, allowing you to see when one of your records loaded, you can check other with this command, but if the records are there, we should be good to edit our domain registrar DNS records to your nameServers we got from the describe command.

I moved 6 domains with very little work. Moving other zonefiles should work. you just need to make sure all of the domain records are utilizing the trailing dot.

Moving a docker container to a new host without dockerhub

Posted Leave a comment

I’m getting started using docker for somethings. I needed to move a container from a test machine to a new production home. This is how I did it. If there is a better way, please let me know!

I ran this where the machine was in development:

on the destination machine I did the following:

once you are done with that, you should be able to see your imported image listed: