Sipsmi's Blog

Techno ramblings of a cynical engineer

Backup to dropbox with duplicity

leave a comment »


  • Assume you have installed duplicity and have a dopbox account?

So I want to backup some essential stuff from my cloud server.  Dropbox pro costs next to nothing for storage and it seems that duplicity has a dropbox backend which can use the dropbox API.

First things first make sure you have the dropbox API python libraries – you can get help here:

Note that the patch is needed ( ) if you are using Ubuntu 14LTS – the file can be found in /usr/lib/python2.7/dist-packages/duplicity/backends on Ubunutu.

Now you need to get an authorisation token to use this with dropbox – in order to do this just run the code and you will be prompted with a URL to do to register an application under  /Apps/duplicity

duplicity /etc dpbx:///test

Follow the URL and authorise the account then press return.  This will save OAuth token to .dropbox.token….  copy this to appropriate home directory if using another account to backup.

Points to remember, every time you use a new base folder you have to create it (use the dropbox web interface), so for that previous one to work I would have to create test under Apps/duplicity

Now I have bundled this all into a script which takes a number of directories and places & backs them up daily (cron invocation) to a number of named folders.


# set destination (other backends are avaialble 🙂
# Setting the pass phrase to encrypt the backup files.
export PASSPHRASE='<somethign complex>'
# declare the directories to be backed up and where to stick-em
declare -A bkupArr
# do the backup
for bkup in ${!bkupArr[@]}
   echo "Backing up $bkup to " $dest/$bkupDest 
   # doing a monthly full backup (1M)
   duplicity --full-if-older-than 1M $bkup $dest/$bkupDest
   # clean backup space 
   duplicity remove-older-than 3M --force $dest/$bkupDest
# Unsetting the confidential variables so they are
# gone for sure.
# quit
exit 0



Disclaimer: This code is from a hardware engineer turned hacker, it most likely aint pretty, it most likely can be done better but …. it works.


Written by sipsmi

February 18, 2016 at 4:05 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s