Blog von tyranus.de

Tag: Duply

10. September 2016

Duply with Dropbox

[Update 2017-10-20: Because Dropbox resigned their API v1]

It is possible to use dropbox as a cloud backend for duplicity or duply for backing up data. While I use duply for server backups this is also possible on linux clients. I am using:

  • Ubuntu 16.04  LTS
  • with its default version of duply
  • a newer version of duplicity (see BackendException: Could not initialize backend: cannot import name client)
  • and with python dropbox  client (v8.4.0)

Needed packages to install

duply and duplicity must both be installed to proceede. duplicity needs the python dropbox backend. On Debian systems you can install it this way:

Some tutorials say to use python library dropbox2 instead. But for me this led to an error while backing up.


For dropbox access in .duply/<name>/conf you only need the following lines:

TARGET  sets dropbox as protocol and <name>  is the folder in dropbox: /Apps/duplicity/<name> . For Dropbox as cloud backend TARGET_USER  must not be set. TARGET_PASS must be set empty. Without it duply will not run. DPBX_ACCESS_TOKEN  must contain a valid dropbox access token for a Dropbox App. This parameter must be exported because duplicity not for duply and duplicity reads it that way.

The config file must of course contain the other parameters used by duply like PGP_PW , SOURCE as for any other backup cloud backend as well. And as for any other backup cloud backend I strongly recommend to only load up encrypted backup files.

Create a new Dropbox App using Dropbox API and an App folder. The App name you chose is the name of the dropbox folder under /Apps. After you created your app generate your access token and paste it to your duply config file and replace <app-token-generated-in-dropbox>.

Now duply can access Dropbox via duplicity with your created dropbox access token.

The python dropbox backend uses the file ~/.dropbox.token_store.txt  to store the credentials in. If this file is missing the next duply call will help to create it. For example try:

If the above file is missing duply will print following output:

After opening the link from the output in the web browser and confirming that the app may access dropbox you have to press Enter in your terminal to proceed. Now the file ~/.dropbox.token_store.txt  should exist and calling duply again should work.

Help with possible Errors

Error: dpbx error: [404] u“Path ‚<name>‘ not found“

You are using the <name>  in your duply configuration within the TARGET  parameter but the Dropbox folder /App/duplicity/<name>  is missing. Just add it.

Error: BackendException: Could not initialize backend: No module named dropbox

The dropbox  python library is missing. Try

Error: dpbx error: [200] ‚Error parsing response body or headers: Body – \x8c\r\x0 …

The problem did not occur with the first backup but with the following ones if I was using dropbox2  python library instead of dropbox .

dpbx error: [400] u’v1_retired‘

Since the End of September 2017 Dropbox retired their API v1. So you have to update your python dropbox client.

BackendException: Could not initialize backend: cannot import name client

07:25:27.701 Task ‚BKP‘ failed with exit code ’23‘.

This will occur if your python dropbox backend is not compatible with duplicity dpbxbackend.py  under /usr/lib/python2.7/dist-packages/duplicity/backends.

For me it occured after fixing the error dpbx error: [400] u’v1_retired‘ with updating dropbox python client.

For Ubuntu 16.04 I updated duplicity to higher version from ppa source to fix it with the following commands:



Help with possible Errors (outdated)

These are common errors with older versions of the duplicity dropbox backend that is not compatible with dropbox API v2.

Error: NameError: global name ‘rest’ is not defined

This is a known bug in the python dropbox backend script. If you have this error you can simply fix it adding the following highlighted line into the file /usr/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py to this position. The bug description is here.

Error: dpbx error: [401] u’Unauthorized‘

Something went wrong with the authorization. Removing (or better moving) the file ~/.dropbox.token_store.txt should help. The next time you are using duply you have to confirm the access of the duplicity backend in your browser again and the file will be recreated.