robinadr

How to: Automated Database Backups to Dropbox

October 13, 2013

From your database to your Dropbox

I’ve spent some time putting together a solution for automated database backups (from MariaDB in this case) to a remote data storage. Since my web host only does backups for my site itself, I was left to find a solution on my own. My goal was to find something that was simple, efficient, and most importantly of all, automated.

Here’s a brief overview of what my backup solution consists of:

  • A bash script is run weekly through cron
  • This script first creates a gzipped database dump using mysqldump
  • The dump is then uploaded to Dropbox1 using Dropbox Uploader
  • Once it’s uploaded to Dropbox, the local copy is deleted

The bash Script

#!/bin/bash

_file="backup-$(date +"%Y-%m-%d").sql.gz"

cd ~
mysqldump --user=username --password=password --host=hostname --databases database1 database2 | gzip >$_file
./dropbox_uploader.sh -q upload $_file "/DB Backups/$_file"
rm $_file

You can download a copy of this script here. Most of it should be self-explanatory. Here’s where you might want to change something:

  • You can change the date format
  • I have it set to upload to the DB Backups folder in the root of my Dropbox; you can set this to whatever you want
  • Put your own database info in to the mysqldump command

Setting Dropbox Uploader Up

dropbox_uploader.sh is a bash script that provides an interface to Dropbox. You can download it from the Github page, and follow the instructions to set it up. Place this file in the same directory as the script above unless you change the reference in the script.

I ended up giving the Uploader script full access to my Dropbox, as I wasn’t sure how to give it application-specific storage and yet still access a folder in the root of my Dropbox.

Backup notification

Once all of this is set up, the script will automatically upload a backup of your database to your Dropbox at whatever interval you set.


  1. This is a referral link; if you sign up with it we both get an extra 500 MB for free. 

My Goodness, My Guinness

September 24, 2013

My Goodness, My Guinness

Spotted in a restaurant bathroom in Portland.

iPhone 4 + iOS 7

September 20, 2013

iOS 7 Lock Screen

I’ve been using iOS 7 on my iPhone 4 for a few days now, and it’s not as bad as I thought it would be. It can get laggy, especially when opening and switching applications, but that’s to be expected. Unfortunately this lag hits a lot while I’m typing. A common problem is the keystrokes being processed lag behind my actual strokes by a fair bit. This happened in iOS 6 too, but the problem now is that it processes me hitting Send or Done before it processes the rest of my keystrokes.

iOS 7 Keyboard

This causes me to accidentally send texts cut in the middle. On iOS 6 this was never a problem so I’m not sure why this behavior changed between versions. Minor inconvenience that I have to adjust for I guess.

The camera is greatly improved. Since it’s still the same hardware, this means the changes must have been made on the software end. That just makes the changes even more impressive. The camera initiates faster, focusing is faster and seems to do a better job, but most importantly of all the camera takes photos much faster.

iOS 7 Camera

I don’t know if this is because they got rid of the shutter animation, but I’m sure that helps make it seem faster. I was having a rough time on iOS 6 with my camera taking forever to open, focus, and take the picture. But now it’s worlds better.

Overall verdict for iOS 7 on an iPhone 4? Bearable. But I think at this point it’s a matter of how long before I break down and get a 5S. The lack of translucency in the UI and missing out on features like Siri, turn-by-turn voice navigation and more are just one nail after the other in my iPhone 4′s coffin. God, I wish I had AirDrop and AirPlay.

At least the iOS 7 lock screen makes my background look awesome.

Don’t Wash Chicken

August 26, 2013

I’ve been told that raw poultry should be washed before you cook it, and that’s what I’ve always done. But it seems that’s a big no-no.

That’s because washing increases the chances that you’ll spread the foodborne pathogens that are almost certainly on your bird all over the rest of your kitchen too, food safety experts say. We’re talking nasty stuff like salmonella and Campylobacter, which together are estimated to cause nearly 1.9 million cases of foodborne illness in the U.S. each year.

Some studies suggest bacteria can fly up to 3 feet away from where your meat is rinsed — though you can’t necessarily see it.

If you aren’t convinced yet, here’s a video simulating where germs get while the chicken’s being washed:

Well, I’m never doing that again.

Telemarketers

August 2, 2013

blocked-calls

Incredible problem here in Hong Kong.