Poor man's database backup using Dropbox

If you’re using a lot of cheap VPS like me, then you you need a way to ship database backups to a third party site. If you’re on EC2, then you’re probably shipping it to Amazon S3. Other providers have their own automated techniques for backup. I have a lot of smaller sites that run on cheap VPS, with no backup solutions. I tend to use dropbox to sync them out to external storage. It’s not the best way, but it’s definitely cheap(read free), and quick to setup. More importanntly you can automatically have them sync to your local or any machines that you want!!!

Dropbox basically designates a folder on your computer as a sync folder. Any changes to that folder are synced to the cloud automatically if the dropbox service is running on local.

Installation

To install dropbox on your server, you simply run the following,

cd ~     wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"

#For x64, use below:
#wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"

tar -tzf dropbox.tar.gz     
tar -xvzf dropbox.tar.gz

Configure

To link your server with an account run the following

~/.dropbox-dist/dropboxd

This will print out a link. You can visit that link and and it will ask you to create an account. This will automatically hookup that dropbox account to your local/server machine that you ran this on.

This client is not linked to any account...     
Please visit https://www.dropbox.com/cli_link?host_id=7aaaaa8f285f2da0x67334d02c1 to link this machine.

Once you’ve signed up you can actually see dropboxd command line acknowledge the account creation. You can close the daemon by running ctrl+c. To run it again in the background so it syncs automatically always, run

~/.dropbox-dist/dropboxd &

Usage

You have to run the dropboxd daemon to sync automatically, so make sure its running by running htop or top. Once you’ve done that, you can also make sure you have a directory called Dropbox on your home folder.

cd ~/Dropbox

To backup anything simply move it to this folder. For eg. i periodically run a cronjob that dumps the live sql database to this folder. See below for an example. You can dump hourly backups of your database this way and they’ll be uploaded to dropbox. You can also set your local machine to use the same account and they’ll be downloaded on your machine as well. Instant gratification!!

mysqldump --single-transaction -h -u -p > ~/Dropbox/dump.sql

More Dropbox tricks to come later.

Source

http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall

5 responses
I was looking for a way to backup VPS database to Dropbox as well (since I couldn't really trust the VPS).

1 suggestion: Configure Dropbox so that it only sync 1 particular folder on server.

>1 suggestion: Configure Dropbox so that it only sync 1 particular folder on server.

Yup, one can do that. The above example is assuming that the dropbox account is solely used to sync this project, since i use it for some of my clients and don't want them to have each others database dumps!!

I'm not sure how much is the Dropbox Daemon overhead. But I'm actually thinking of writing a small server script in Python to utilize Dropbox API to transfer DBs to Dropbox, and set the script to run through cronjob.
I just did a post about this on my mew blog =)

Thank you for spreading the information!

Hmm, what's the max filesize limit of dropbox for free users? I will give this a try, thanks.