From f8e1664e0130f4b79bfeffe0ccc89773b23365b9 Mon Sep 17 00:00:00 2001 From: intrigeri <intrigeri@boum.org> Date: Tue, 25 Jul 2017 09:55:13 +0000 Subject: [PATCH] dup handler: correctly handle Dropbox access token (Closes: #11260). Thanks to Daniel Lo Nigro for the patch. --- AUTHORS | 1 + examples/example.dup | 11 +++++++++++ handlers/dup.helper.in | 11 +++++++++++ handlers/dup.in | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/AUTHORS b/AUTHORS index 93fbc17..085e5fa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -55,3 +55,4 @@ Christian Prause <cprause@suse.com> -- Support suse in the sys handler Jools Wills <jools@oxfordinspire.co.uk> -- Bugfix in the sys helper, indentation fixes Mark Janssen <mark@sig-io.nl> -- ignore jobs whose filename ends with "~" shred <riseup@ml.shredzone.de> -- Initial patch for test mode support in the rsync handler +Daniel Lo Nigro <daniel@dan.cx> -- Dropbox support for Duplicity diff --git a/examples/example.dup b/examples/example.dup index 067b6b1..9b60f77 100644 --- a/examples/example.dup +++ b/examples/example.dup @@ -189,6 +189,7 @@ exclude = /var/cache/backupninja/duplicity ## desturl = rsync://user@other.host//var/backup/bla ## desturl = s3+http:// ## desturl = ftp://myftpuser@ftp.example.org/remote/ftp/path +## desturl = dpbx:///myserver ## the default value of this configuration option is not set: ## ## Default: @@ -213,6 +214,16 @@ exclude = /var/cache/backupninja/duplicity # cfapikey = # cfauthurl = +## Dropbox requires a valid authentication token. To obtain one, you will need +## to create a Dropbox API application at https://www.dropbox.com/developers/apps/create. +## See the "A note on Dropbox access" section of the Duplicity manpage for more +## details: http://duplicity.nongnu.org/duplicity.1.html#sect12 +## +## Default: +# dropboxappkey = +# dropboxappsecret = +# dropboxaccesstoken = + ## FTP password, needed for backups using desturl = ftp://... ## ## Default: diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 6f3281e..a6050af 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -470,6 +470,7 @@ keepincroffulls = $dup_keepincroffulls #desturl = rsync://user@other.host//var/backup/bla #desturl = s3+http://your_bucket #desturl = ftp://myftpuser@ftp.example.org/remote/ftp/path +#desturl = dpbx:///myserver # Amazon Web Services Access Key ID and Secret Access Key, needed for backups # to S3 buckets. @@ -486,6 +487,16 @@ keepincroffulls = $dup_keepincroffulls # cfapikey = # cfauthurl = +## Dropbox requires a valid authentication token. To obtain one, you will need +## to create a Dropbox API application at https://www.dropbox.com/developers/apps/create. +## See the "A note on Dropbox access" section of the Duplicity manpage for more +## details: http://duplicity.nongnu.org/duplicity.1.html#sect12 +## +## Default: +# dropboxappkey = +# dropboxappsecret = +# dropboxaccesstoken = + # FTP password, needed for backups using desturl = ftp://... #ftp_password = diff --git a/handlers/dup.in b/handlers/dup.in index 3c586c6..43b282f 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -34,6 +34,9 @@ getconf awssecretaccesskey getconf cfusername getconf cfapikey getconf cfauthurl +getconf dropboxappkey +getconf dropboxappsecret +getconf dropboxaccesstoken getconf ftp_password getconf sshoptions getconf bandwidthlimit 0 @@ -54,6 +57,16 @@ fi if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "cf+http" ]; then [ -n "$cfusername" -a -n "$cfapikey" ] || fatal "Cloudfiles access keys must be set for S3 backups." fi +if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "dpbx" ]; then + [ -n "$dropboxappkey" -a -n "$dropboxappsecret" ] || fatal "Dropbox app ID and secret must be set for Dropbox backups." + + if [ ! -n "$dropboxaccesstoken" ]; then + error "To obtain an access token for Dropbox, you will need to manually run this command:" + error "DPBX_APP_KEY=$dropboxappkey DPBX_APP_SECRET=$dropboxappsecret duplicity list-current-files $desturl" + fatal "Dropbox access token must be set" + fi +fi + if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "ftp" ]; then [ -n "$ftp_password" ] || fatal "ftp_password must be set for FTP backups." fi @@ -279,6 +292,13 @@ if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "cf+http" ]; then fi fi +### If desturl is a Dropbox URL, export the relevant environment variables +if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "dpbx" ]; then + export DPBX_APP_KEY="$dropboxappkey" + export DPBX_APP_SECRET="$dropboxappsecret" + export DPBX_ACCESS_TOKEN="$dropboxaccesstoken" +fi + ### Cleanup commands (duplicity >= 0.4.4) # cleanup -- GitLab