Server Backups Using Git

At work, I’ve fallen in love with Git for our revision software. A co-worker told me that he uses Git to automatically backup his entire home directory on his computer, so I figured I could do something similar with the VPS that hosts this website.

There are two things required to make this work: Git, and a destination server to push your backup to.

The script I’m using is copied below (password redacted for security).


DATE=$(date +%Y-%m-%d) 

pushd ~/backup 
mysqldump -u $MYSQLUSER -p$MYSQLPASS --all-databases > mysql/alldb.sql
cp -r /var/www/* www/

git add .
git commit -s -m "$DATE"
git push origin master


All in all, pretty basic as far as things go. Dump the entire MySQL/MariaDB database, copy all the bare files from the /var/www directory, and then commit them to git. The other advantage of this is that it’s dead simple to restore a backup from any previous date. The nice advantage of using git is that it’s entirely OS agnostic, so I can restore the contents from one system to the other with minimal difficulties.

When extra security would have failed

I took a trip to Los Angeles to visit a friend. Updated FAA regulations have allowed the use of small electronic devices during take-off and landing, but no laptops. I don’t have any games on my phone, so I pulled out my Kobo Aura to read for a bit. A few minutes into our flight, the “Fasten Seatbelt” turned off, and I put my Kobo in the seat-back pouch before pulling out my Chromebook to watch a movie.

When I arrived at my friend’s appartment and started unpacking, I realized that I had forgotten the Kobo on the plane. I immediately filed a report with Alaska’s Lost-and-Found website, hoping that somehow the Kobo would get back to me. I gave a detailed description of the device (Black Kobo aura with leather cover. Current book is Garden of Rama.) and my contact information. After several days, I started to lose hope, and began preparing myself to buy another when I got back home.

The night after I returned home, an employee from Alaska Airlines emailed me saying that they had found the Kobo! I immediately called them back (it was 11:30 PM, but they had just sent the email) and arranged to have another friend pick it up from LAX the next day.

It turns out, Alaska hadn’t contacted me via my lost-and-found ticket. They opened the Kobo (which doesn’t have any form of security) and managed to find my email address in the “Accounts” section of the settings. I’m curious as to whether or not I would have got it back if my contact info wasn’t as readily available.

On a low privacy risk device such as an e-reader, having a pin lock is unnecessary in most cases. As a result, someone was able to contact me to return my device. On a higher-risk device such as a tablet or smartphone, putting owner or ICE (In Case of Emergency) contact info is easy to implement, and may just help you get a lost device back.

From the walled garden to open fields

I made the jump from dumb phones to smart phones about three years ago with the purchase of an iPhone4 from my carrier. Like many others, I was blown away by the convenience of having my digital life at my fingertips.

Fast forward about two and a half years. The iPhone4 was starting to show its age. From all the previews I had seen about iOS7, I wasn’t all that amazed. A new iPhone5 would still cost me upwards of $700, or I’d have to renew my contract with my carrier (Canadian telecoms are running a pretty tight oligopoly) to be eligible for a discount.

Then came the announcements for the Nexus5. The more I saw, the more I got excited. After getting frustrated with some of the limitations in the Appleverse, I switched to Android.

It’s been a great year – more posts to come with some of the awesome stuff you can do on Android.

New VPS hosting

After over seven years, I finally got fed up with Dreamhost.

I’ve signed up for VPS services with tmzVPS, which gives me far more control over how the server operates. Dreamhost is fine if you want them to manage everything for you, but ask for any sort of administrative permissions (even on their “VPS” services) and you’re quickly going to run into troubles. I’ll be posting a bit more in the future about some of the specifics.

This setup also allows me to proxy into the US to access Pandora and Netflix. 😀

I remembered! Sort of….

So, continuing my challenge. I meant to post this up earlier (it’s technically Tuesday now), but I got distracted with other things.

In current news, my girlfriend and I are making a trip to Hawaii next week with a few friends. I’m really looking forward to getting away from the city for a while (not that I don’t love Vancouver) and finally getting my fins wet while scuba diving again. I might have to take a bit of a break on this whole ‘post every two days’ thing while I’m away, depending on internet availability. I’ll try to get something up and running though.

I’ve also been putting a bit of spare time into getting my Youtube channel a little more streamlined and putting a few more videos up on there in order to increase it’s popularity. Most of my videos are probably going to be related to World of Warcraft (I’m currently in a progression guild at the moment), but there will be some other videos as well. Zxian’s Youtube Channel.

Now it’s time for sleep.

© 2022 Zxian's Blog

Theme by Anders NorénUp ↑