01143b6834cc22a5c137634553b7ad0a61c0bbcd

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

Message

Size GCS with gsutil

Diff

This diff is truncated to protect this page.

 1diff --git a/README.md b/README.md
 2index 45e1367bdae275d5362bf685940f7b8399144b02..9d64de92a5baaec864797252ba5fdd96fcfc983a 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -50,6 +50,11 @@ Be sure to make the script executable (`chmod +x`) before you hit the gas.
 6diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 7index 2affd82e07f187127b0b8eeb19ce55b975029982..be29261280da5c9d00e6f9e3e6bc7d6434fd777b 100755
 8--- a/duplicity-backup.sh
 9+++ b/duplicity-backup.sh
10@@ -214,6 +214,11 @@ elif [ "$ENCRYPTION" = "no" ]; then
11   ENCRYPT="--no-encryption"
12 fi
13 
14+NO_GSCMD="WARNING: gsutil no found in PATH, remote file \
15+size information unavailable."
16+NO_GSCMD_CFG="WARNING: gsutil is not configured, run 'gsutil config' \
17+in order to retrieve remote file size information. Remote file \
18+size information unavailable."
19 NO_S3CMD="WARNING: s3cmd no found in PATH, remote file \
20 size information unavailable."
21 NO_S3CMD_CFG="WARNING: s3cmd is not configured, run 's3cmd --configure' \
22@@ -228,6 +233,17 @@ fi
23 
24 if  [ "`echo ${DEST} | cut -c 1,2`" = "gs" ]; then
25   DEST_IS_GS=true
26+  GSCMD="$(which gsutil)"
27+  if [ ! -x "$GSCMD" ]; then
28+    echo $NO_GSCMD; GSCMD_AVAIL=false
29+  elif [ ! -f "${HOME}/.boto" ]; then
30+    echo $NO_GSCMD_CFG; GSCMD_AVAIL=false
31+  else
32+    GSCMD_AVAIL=true
33+    GSCMD="${GSCMD}"
34+  fi
35+else
36+  DEST_IS_GS=false
37 fi
38 
39 if  [ "`echo ${DEST} | cut -c 1,2`" = "s3" ]; then
40@@ -416,8 +432,10 @@ get_remote_file_size()
41     ;;
42     "gs")
43       FRIENDLY_TYPE_NAME="Google Cloud Storage"
44-      #TMPDEST=`echo ${DEST} | cut -c 4-`
45-      #SIZE=`du -hs ${TMPDEST} | awk '{print $1}'`
46+      if $GSCMD_AVAIL ; then
47+        TMPDEST=`echo $DEST | sed -e "s/\/*$//" `
48+        SIZE=`gsutil du -s ${TMPDEST} | awk '{print $1}'`
49+      fi
50     ;;
51     "s3")
52       FRIENDLY_TYPE_NAME="S3"
53@@ -799,6 +817,8 @@ fi
54 
55 unset AWS_ACCESS_KEY_ID
56 unset AWS_SECRET_ACCESS_KEY
57+unset GS_ACCESS_KEY_ID
58+unset GS_SECRET_ACCESS_KEY
59 unset PASSPHRASE
60 unset SIGN_PASSPHRASE
61 unset FTP_PASSWORD