8abfd40c302fb64d03a961186672f7542959920a

Author
Giovanni Pini <giovanni.pini@gmail.com>
Committer
Giovanni Pini <giovanni.pini@phoops.it>
Date

Message

Google Cloud Storage support

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index 6f27460d5fc0caa5b09b759ecc935174bae1a710..ef21eb46aaa0dd0b7b4b8c03d7d686755cedac77 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -46,6 +46,11 @@
 6 AWS_ACCESS_KEY_ID="foobar_aws_key_id"
 7 AWS_SECRET_ACCESS_KEY="foobar_aws_access_key"
 8 
 9+# GOOGLE CLOUD STORAGE INFORMATION
10+# Comment out these lines if you're not using Google Cloud storage
11+GS_ACCESS_KEY_ID="foobar_gcs_key_id"
12+GS_SECRET_ACCESS_KEY="foobar_gcs_secret_id"
13+
14 # S3CMD INFORMATION
15 # Most people don't need this, but in some cases
16 # you may want to specify a custom configuration file
17@@ -117,6 +122,7 @@ DEST="s3+http://foobar-backup-bucket/backup-folder/"
18 # Be sure to check duplicity's man page to know how to use them
19 # (http://duplicity.nongnu.org/duplicity.1.html)
20 #
21+#DEST="gs://foobar-backup-bucket/backup-folder/"
22 #DEST="ftp://user[:password]@other.host[:port]/some_dir"
23 #DEST="rsync://user@host.com[:port]//absolute_path"
24 #DEST="scp://user[:password]@other.host[:port]/[/]some_dir"
25diff --git a/duplicity-backup.sh b/duplicity-backup.sh
26index 1a093f99294c0a3cc6c8c4fd8bec5dd1161c8059..2affd82e07f187127b0b8eeb19ce55b975029982 100755
27--- a/duplicity-backup.sh
28+++ b/duplicity-backup.sh
29@@ -171,6 +171,8 @@ STATIC_OPTIONS="$DRY_RUN$STATIC_OPTIONS"
30 SIGN_PASSPHRASE=$PASSPHRASE
31 export AWS_ACCESS_KEY_ID
32 export AWS_SECRET_ACCESS_KEY
33+export GS_ACCESS_KEY_ID
34+export GS_SECRET_ACCESS_KEY
35 export PASSPHRASE
36 export SIGN_PASSPHRASE
37 if [[ -n "$FTP_PASSWORD" ]]; then
38@@ -224,6 +226,10 @@ if [ ! -x "$DUPLICITY" ]; then
39   exit 1
40 fi
41 
42+if  [ "`echo ${DEST} | cut -c 1,2`" = "gs" ]; then
43+  DEST_IS_GS=true
44+fi
45+
46 if  [ "`echo ${DEST} | cut -c 1,2`" = "s3" ]; then
47   DEST_IS_S3=true
48   S3CMD="$(which s3cmd)"
49@@ -270,6 +276,8 @@ check_variables ()
50   [[ ${LOGDIR} = "/home/foobar_user_name/logs/test2/" ]] && config_sanity_fail "LOGDIR must be configured"
51   [[ ( ${DEST_IS_S3} = true && (${AWS_ACCESS_KEY_ID} = "foobar_aws_key_id" || ${AWS_SECRET_ACCESS_KEY} = "foobar_aws_access_key" )) ]] && \
52   config_sanity_fail "An s3 DEST has been specified, but AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY have not been configured"
53+  [[ ( ${DEST_IS_GS} = true && (${GS_ACCESS_KEY_ID} = "foobar_gcs_key_id" || ${GS_SECRET_ACCESS_KEY} = "foobar_gcs_secret_id" )) ]] && \
54+  config_sanity_fail "A Google Cloud Storage DEST has been specified, but GS_ACCESS_KEY_ID or GS_SECRET_ACCESS_KEY have not been configured"
55   [[ ! -z "$INCEXCFILE" && ! -f $INCEXCFILE ]] && config_sanity_fail "The specified INCEXCFILE $INCEXCFILE does not exists"
56 }
57 
58@@ -406,6 +414,11 @@ get_remote_file_size()
59       TMPDEST=`echo ${DEST} | cut -c 6-`
60       SIZE=`du -hs ${TMPDEST} | awk '{print $1}'`
61     ;;
62+    "gs")
63+      FRIENDLY_TYPE_NAME="Google Cloud Storage"
64+      #TMPDEST=`echo ${DEST} | cut -c 4-`
65+      #SIZE=`du -hs ${TMPDEST} | awk '{print $1}'`
66+    ;;
67     "s3")
68       FRIENDLY_TYPE_NAME="S3"
69       if $S3CMD_AVAIL ; then