There are a lot of backup solution and options available, but most of them are for business and professional usage. If you need free and simple solution that works on any Linux distribution then consider reading this article. As you know DropBox offers 2 GB of free storage. If you refer your friends to Dropbox, you can earn up to 16 GB of additional space. This is more than enough to backup a WordPres site for example.
Advertisements
To setup simple backup solution that uses DropBox you need of three things: DropBox account, curl and script called dropbox_uploader.sh. Most probably you already have DropBox account, but if you don’t have one, register one for free from here.
Also make sure that you refer some friends to sign in order to get some more free space.
Next you need to install a cURL. cURL is a command line tool for transferring data using various protocols – FTP, FTPS, HTTP, HTTPS and many more. Another similar project is wget. Anyway curl is available on all major Linux distributions.
Advertisements
To install it on Ubuntu / Debian
sudo apt-get install curl
To install it on Fedora
yum install curl
After that you need to download and install DropBox Uploader. As name suggests Dropbox Uploader is a simple bash script which can be used to upload, download, delete, and do much more with Dropbox.
To download and install it execute the following commands:
mkdir dropbox cd dropbox curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh chmod 755 dropbox_uploader.sh ./dropbox_uploader.sh
First make a directory where to download it, then navigate to this directory. Third command actually downloads dropbox_uploader.sh. Then give the execution permission to the script. And finally execute script.
When script is executes for the first time it will ask you couple of questions. So be prepared to login to your DropBox account and to perform required tasks.
Next step is to login to you DropBox account and to go to the following address – https://www2.dropbox.com/developers/apps. Then click the button Create App.
On next screen you have to select Dropbox API app. Look into screenshots for more details.
On next screen you have to select Files and datastores. Look into screenshots for more details.
Then on next question “Can your app be limited to its own folder?” for maximum security select Yes – My app only needs access to files it creates.
And finally give some name for that App. In our case HowOpenSourceBackup and click Create app button.
Now you app is created on next screen some information is present and you need to enter that information into your dropbox uploader script. So copy and paste following information from you browser to you terminal window.
Finally it should look something like that. Script asks you to copy and paste some URL from terminal to browser in order to allow access of DropBox Uploader script to this new created app.
When you copy and paste authorization URL that DropBox Uploader script generates, you will be asked to confirm access to that app. So click “Allow” and you have to be ready. You can find this new created folder in DropBox account into following path Files/Apps/HowOpenSourceBackup in our case. So you can delete or see what is uploaded here from script.
To test that everything is OK you can try to upload some test file. So what about to upload the dropbox_uploader.sh script itself. In order to test that it works simply run the command:
./dropbox_uploader.sh upload dropbox_uploader.sh .
Now when you go to you DropBox account and application folder you will see that you have one file dropbox_uploader.sh. You can delete it as it was just simple test.
Script dropbox_uploader.sh has similar format options to cp and mv commands. So if you are familiar with them should not be a problem to start using it.
howopensource@debian:~/dropbox$ ./dropbox_uploader.sh
Dropbox Uploader v0.14
Andrea Fabrizi - andrea.fabrizi@gmail.com
Usage: ./dropbox_uploader.sh COMMAND [PARAMETERS]...
Commands:
upload
download [LOCAL_FILE/DIR]
delete
move
copy
mkdir
list [REMOTE_DIR]
share
info
unlink
Optional parameters:
-f Load the configuration file from a specific file
-s Skip already existing files when download/upload. Default: Overwrite
-d Enable DEBUG mode
-q Quiet mode. Don't show messages
-p Show cURL progress meter
-k Doesn't check for SSL certificates (insecure)
For more info and examples, please see the README file.
As you see most of commands are self explanatory.
If you want to run script dropbox_uploader.sh automatically as cron job you have to consider some additional steps in mind. For example you execute script as you regular user, but when run under cron job it may needs path to it’s configuration file. So use option -f
On script wiki page are some good example of how to run it automatically to backup your data via cron job.
Basically you have to consider two things in mind – path to script dropbox_uploader.sh and to specify path to configuration file. Other stuff that you have to keep in mind is that you have to generate file backup name using date. Also should consider deleting old backup files to free some space. For example calculate how many backup files you can store on space that you have. And consider deleting files that are more than one month old. This can be done also via this script.
DELDATE=`date --date="-30 day" +%Y%m%d`
./dropbox_uploader.sh delete backup-${DELDATE}.tar.gz
Consider adding above snippet at the end of backup script that is run by cron job.
Hope this article gives you basic idea how to setup simple and easy backup on linux computers to widely used DropBox.













