As described in my previous post I use Duplicity with Google Drive for storage. In this post I give a quick how to on configuring Duplicity for that setup.


  • Duplicity installed
  • PyDrive, I installed it from Arch Linux's Aur repository
  • GPG keys configured
  • A Google Drive account
  • First time you run Duplicity it has to be done interactively, as it will prompt you to allow access to Google drive

Google drive API setup

Go to and create a new project, under "Show advanced options > App Engine location" I selected "europe-west".

  1. Select "Google Drive API" and enable, then select "Credentials" in the menu to the left
  2. Fill out "OAuth consent screen"
  3. Click "Create credentials" in the popup and select "OAuth client ID" in the dropdown
  4. Select "Other" and give the client a name
  5. Download the JSON file, save it as /root/.duplicity/client_secrets.json . Put the "Client ID" and "Client secret" in /root/.duplicity/gdrive (see below)

Create /root/.duplicity/gdrive and add the values from step 5:

client_config_backend: settings
save_credentials: True
save_credentials_backend: file
save_credentials_file: gdrive.cache
get_refresh_token: True

Granting Duplicity access to Google drive

PyDrive would prompt for a verification code everytime I ran Duplicity, and would not create the gdrive.cache file. I fixed it by changing the current working directory to /root/.duplicity/ . A simple script like the following should work:

cd /root/.duplicity/


duplicity incr --encrypt-key XXXXXXX --full-if-older-than 4M --volsize 1024 --asynchronous-upload --exclude-device-files --exclude-other-filesystems "${SRC}" "${DEST}"

When you run this script the first time, you should get a prompt that says (XXXXXXXXXXXXXXXXXXXXXX will be your client id):

Go to the following link in your browser:

Enter verification code:

When you have approved access you should have the file /root/.duplicity/gdrive.cache , and next time Duplicity runs, it should automatically be authorized.

Wrapping up

I have created a set of Duplicity backup scrips with error handling/reporting that wraps backup, restore, cleanup and backup verification, feel free to use or fork them :)