Raspberry Pi: Integration with Dropbox

Dropbox is a Cloud Storage area that’s free to use for private individuals for relatively large quantities of data. I like it for my Raspberry Pi network because it allows me to move files to devices that are not on my home network without having to open up either the home network or the distant network too much (one has to rely on Dropbox’s security but one would hope that they are relatively secure.

The Dropbox_Uploader is a BASH script, written by Andrea Fabrizi and allows you to upload/download/delete and otherwise manipulate files in the designated Dropbox area either directly or with Python programs. Details are available here¬†and I have not intention of duplicating it because it would mean that I’d have to keep it up to date as there are changes either to the Uploader or to Dropbox.

Dropbox_Uploader is simple to call from a cronjob, so I use it to back-up the files shared to my “network master” Pi from the “slave” Pis on a daily basis so that I’ve got additional levels of security. There are a few things to remember when setting up the cronjob, and the one that I forget most easily is making sure that Dropbox_Uploader is available to the user executing the cronjob (i.e. if you load dropbox-uploader in the pi user, the cronjob must be created by the pi user otherwise it won’t be found and the cronjob will fail.

To upload a file, the cronjob command is:

/path/to/dropbox-uploader.sh sourcedir/file destdir/file

Scheduled to run as often as you like.

One example of repeat uses is that if you’ve set up a camera that triggers on movement (for example) you can run a cronjob every minute that checks for files and moves them up to Dropbox for security or examination from a remote device (such as your smartphone).