How to automatically backup MySQL database to Dropbox

Ever wanted to backup your MySQL database to Dropbox automatically. Well, there is a nice portable solution with Dropbox Uploader. Dropbox Uploader is a BASH script which can be used to upload, download, delete, list files, move, copy and much more from Dropbox. It’s written in the BASH scripting language and only needs cURL to work. I’ve tested it on my Windows/Cygwin environment at it works like a charm.


It is a very small script so quick to clone from the repository with git:

git clone

or, download with curl. I myself downloaded using curl:

curl "" -o

Once downloaded change the appropriate permissions and run it.

$chmod +x

The first time you run dropbox_uploader (, you’ll be guided through a wizard in order to configure access to your Dropbox account. This configuration will be stored in ~/.dropbox_uploader.


Once the initial configuration is done you can upload your MySQL database file as below. The format for the BASH script is:


An example is given below. ‘file-location’ is the local directory path where the MySQL backup sql file is located. /myfiles/db.sql is the remove Dropbox directory location with the filename.

$ ./ upload /file-location/db.sql /myfiles/db.sql

You can add the above line to your CRON job to automatically upload your MySQL database file from your preferred location. Note that you will need to mention the full path to the ‘’ file in your CRON (e.g. /path/to/

I’ve not mentioned on how to backup your MySQL database as there are many options one could take, like using ‘mysqldump‘ or some other method.

A simple example to dump a complete database is to use the following.

mysqldump -u [uname] -p[pass] db_name > db_backup.sql

Or all the databases. Note that this file can be quite huge.

mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql

Note that if the file is bigger than 150Mb the file is uploaded using small chunks (default 4Mb); in this case a . (dot) is printed for every chunk successfully uploaded and a * if an error occurs (the upload is retried for a maximum of three times). Only if the file is smaller than 150Mb, the standard upload API is used, and if the -p option is used the default curl progress bar is displayed during the upload process.

A detailed list of commands is given here with the various options.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>