LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Tutorial - How to Backup your Ubuntu VPS to DropBox

Automatically backing up files from a VPS to your DropBox account is simpler than you might think.

When you configure your VPS to automatically send backups to your DropBox storage account, you can be assured that critical files on your VPS are backed up in a cloud data center that features multiple levels of redundancy.

This type of backup scheme could be necessary for critical apps running on a VPS. If you found yourself in a disaster recovery scenario, it would be much easier to restore your files from a cloud backup than to wait on your data center to find the files on a tape backup.

In this article, we will assume you are using the last version of Ubuntu 16.04. So let’s get started! We will also assume that you already have a DropBox account. If you do not, go ahead and register for a free account now by visiting:

Once you are logged in, copy and paste the following address into your browser:

Click the “Create App” button and then select the following from the first question:

  • DropBox API

In the section titled “2. Choose the type of access you need” select:

  • App folderAccess to a single folder created specifically for your app.

Now select a name for your app, in our example we will use “easyBackup”. Accept the Terms and Conditions and then click “Create App”.

On the next screen you will need to press the “Generate” button under the section titled “Generate access token”, take note of the code and keep it since we will be using it in the next steps.

Now that our DropBox account is ready, let’s configure our VPS. First, we must install cURL. cURL is a command line tool for transferring data using various protocols – FTP, FTPS, HTTP, HTTPS and many more. To install it on our VPS, type the following command in an SSH session:

> sudo apt-get install curl

You will now need to download and install the DropBox Uploader script. As name suggests, the Dropbox Uploader is a simple bash script which can be used to upload, download, delete, and manipulate files with DropBox. To download and install it, simply 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

When the script is executed for the first time, it will ask you to customize your install. It will prompt you for the Access Token that we generated in previous steps. Copy and paste that into the terminal session and answer yes to the next question.

To test that everything is OK, let’s try to upload the dropbox_uploader.sh script itself. Simply run the following command:

> ./dropbox_uploader.sh -k upload dropbox_uploader.sh .

When you go to your DropBox account, you should now see the application folder and inside of it a folder with the name of your app, in this case “easyBackup”.

We are now ready to set up our daily backup script. Let’s create the following file in our home directory on the VPS:

> vim backup.sh

We are using vim, but you may use the editor that you prefer. Paste the following lines into the new file:




DATE=$(date +”%d-%m-%Y_%H%M”)


BKP_DIRS=”/var/www /etc”


tar cf “$BKP_FILE” $BKP_DIRS

gzip “$BKP_FILE”

$DROPBOX_UPLOADER -f /root/.dropbox_uploader upload “$BKP_FILE.gz” /

rm -fr “$BKP_FILE.gz”


In this example we are assuming you will backup the following directories:



In case you will want to change or add different ones, simply modify the following line of the script:

BKP_DIRS=”/dir1 /dir2 /dir3 … /dirX”

Now let’s add execution permissions to the backup script using the following command:

> chmod 755 backup.sh

The last step is to add the following line to the crontab:

00 00 * * * /path/to/backup.sh 2>&1 >> /var/log/backup.log

This will execute the script every night at 12AM and generate a log with the output of the execution.

Keep in mind that your DropBox account is not limitless, so remember to clean up some of the older files to avoid going past your quota.

If you’d rather not deal with the process of cleaning up your old backups, use this version of the script that only generates a single backup file. The caveat is that the previous day’s backup is overwritten when the newest backup job is executed. Use the same process described above with the following script:





BKP_DIRS=”/var/www /etc”


tar cf “$BKP_FILE” $BKP_DIRS

gzip “$BKP_FILE”

$DROPBOX_UPLOADER -f /root/.dropbox_uploader upload “$BKP_FILE.gz” /

rm -fr “$BKP_FILE.gz”



  1. I like to use duplicity

    August 30, 2016 @ 2:53 am | Reply
  2. i am dropbox user also get 50gb free from promotion samsung..
    i will try now

    August 30, 2016 @ 2:24 pm | Reply
  3. try rclone.

    August 30, 2016 @ 11:49 pm | Reply
  4. Jordan:

    I think I’ll avoid Dropbox at the moment!

    September 1, 2016 @ 2:02 pm | Reply
  5. Make centos version it will be awesome. thanks for the tutorial it will be usefull for ubuntu user out there!.

    September 1, 2016 @ 4:13 pm | Reply
  6. Alex:

    Is there any way to do this with onedrive or baidu yun?

    September 2, 2016 @ 8:53 am | Reply
  7. +1 for rclone

    September 3, 2016 @ 4:47 am | Reply
  8. Graham:

    A nice script. Is there any reason not to default to the same remote file name as the local name without requiring the . on the end of the upload command ? An option to display either the transfer rate achieved (MB/s or KB/s) or time taken for the transfer would also be useful as some may choose to run it manually and have a idea of how long the transfer of large file(s) might take.

    September 12, 2016 @ 7:49 pm | Reply
  9. Greate post, but your website font and font size is hard to read

    October 21, 2016 @ 1:47 pm | Reply
  10. Jim:

    Great article. Now a stupid question: once you’ve backed up, how do you restore?

    February 21, 2021 @ 10:49 pm | Reply
  11. Jim:

    OK, stupid noob question: THe article provides excellent information about backing up. So how do you restore?

    February 22, 2021 @ 7:58 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

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