0

I'm trying to use duplicity to backup my files from my Linux desktop.

I read the answer to this question How do I backup to google drive using duplicity? dating from 2015 but it might be obsolete ?

From the duplicity documentation, https://duplicity.gitlab.io/stable/duplicity.1.html, I understand I have to :

  1. Go to https://console.developers.google.com and create a projet, which I did. Name: mybackup-12345 (I changed the name for this question)
  2. create an oauth access, and get the secret in a json file. My json file content is as follow (/home/myuser/backups/google_client_secret_json_file.json):
{
    "installed":{
        "client_id":"XXXXXXXX.apps.googleusercontent.com",
        "project_id":"mybackup-12345","auth_uri":"https://accounts.google.com/o/oauth2/auth",
        "token_uri":"https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
        "client_secret":"XXXXXXX",
        "redirect_uris":["http://localhost"]
    }
}
  1. export GOOGLE_SERVICE_JSON_FILE=/home/myuser/backups/google_client_secret_json_file.json
  2. export GOOGLE_CREDENTIALS_FILE=/home/myuser/backups/google_credentials_file (this file does not exist yet, I supposed that duplicity would create it after the first login)
  3. export GOOGLE_SERVICE_ACCOUNT_URL="mybackup-12345@mybackup-12345.iam.gserviceaccount.com"
  4. And finally launch duplicity: duplicity /home/myuser/Documents gdrive://${GOOGLE_SERVICE_ACCOUNT_URL}/backups/documents?myDriveFolderID=root

I tried other values before, but I guess this should not be far from what I should do. But I get this (python) error now :

google.auth.exceptions.MalformedError: Service account info was not in the expected format, missing fields client_email, token_uri.

Jean Coiron
  • 632
  • 8
  • 24

1 Answers1

1

Based on your google\_client\_secret\_json\_file.json file, this doesn't contain the json objects needed and as explained by the error google.auth.exceptions.MalformedError: Service account info was not in the expected format, missing fields client\_email, token\_uri. You will need to generate a Service Account key instead by following this reference article.

image

Sample format for Service Account credentials:

{
  "type": "service_account",
  "project_id": "[PROJECT ID]",
  "private_key_id": "[PRIVATE KEY ID]",
  "private_key": "-----BEGIN PRIVATE KEY----- [PRIVATE KEY HERE] -----END PRIVATE KEY-----\n",
  "client_email": "[SERVICE ACCOUNT EMAIL]",
  "client_id": "[CLIENT-ID]",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[EMAIL].iam.gserviceaccount.com",
  "universe_domain": "googleapis.com"
}
Century Tuna
  • 1,378
  • 1
  • 6
  • 13