771c2715be79b070996acac971c1282f66900b98
- Author
- zertrin <zertrin@gmail.com>
- Committer
- zertrin <zertrin@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/README.md b/README.md
2index 32767ae684a61fc0739dd13388d319d44fa5b9af..9d64de92a5baaec864797252ba5fdd96fcfc983a 100644
3--- a/README.md
4+++ b/README.md
5@@ -1,6 +1,6 @@
6 # duplicity-backup.sh
7
8diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
9index 6f27460d5fc0caa5b09b759ecc935174bae1a710..ef21eb46aaa0dd0b7b4b8c03d7d686755cedac77 100644
10--- a/duplicity-backup.conf.example
11+++ b/duplicity-backup.conf.example
12@@ -46,6 +46,11 @@
13 AWS_ACCESS_KEY_ID="foobar_aws_key_id"
14 AWS_SECRET_ACCESS_KEY="foobar_aws_access_key"
15
16+# GOOGLE CLOUD STORAGE INFORMATION
17+# Comment out these lines if you're not using Google Cloud storage
18+GS_ACCESS_KEY_ID="foobar_gcs_key_id"
19+GS_SECRET_ACCESS_KEY="foobar_gcs_secret_id"
20+
21 # S3CMD INFORMATION
22 # Most people don't need this, but in some cases
23 # you may want to specify a custom configuration file
24@@ -117,6 +122,7 @@ DEST="s3+http://foobar-backup-bucket/backup-folder/"
25 # Be sure to check duplicity's man page to know how to use them
26 # (http://duplicity.nongnu.org/duplicity.1.html)
27 #
28+#DEST="gs://foobar-backup-bucket/backup-folder/"
29 #DEST="ftp://user[:password]@other.host[:port]/some_dir"
30 #DEST="rsync://user@host.com[:port]//absolute_path"
31 #DEST="scp://user[:password]@other.host[:port]/[/]some_dir"
32diff --git a/duplicity-backup.sh b/duplicity-backup.sh
33index 45c95aaf9ec6295a447d8edfe068f9ad12aa543e..27c36e7dbde139050d6df5adc2f8ffd0c3629c23 100644
34--- a/duplicity-backup.sh
35+++ b/duplicity-backup.sh
36@@ -171,6 +171,8 @@ STATIC_OPTIONS="$DRY_RUN$STATIC_OPTIONS"
37 SIGN_PASSPHRASE=$PASSPHRASE
38 export AWS_ACCESS_KEY_ID
39 export AWS_SECRET_ACCESS_KEY
40+export GS_ACCESS_KEY_ID
41+export GS_SECRET_ACCESS_KEY
42 export PASSPHRASE
43 export SIGN_PASSPHRASE
44 if [[ -n "$FTP_PASSWORD" ]]; then
45@@ -212,6 +214,11 @@ elif [ "$ENCRYPTION" = "no" ]; then
46 ENCRYPT="--no-encryption"
47 fi
48
49+NO_GSCMD="WARNING: gsutil not found in PATH, remote file \
50+size information unavailable."
51+NO_GSCMD_CFG="WARNING: gsutil is not configured, run 'gsutil config' \
52+in order to retrieve remote file size information. Remote file \
53+size information unavailable."
54 NO_S3CMD="WARNING: s3cmd not found in PATH, remote file \
55 size information unavailable."
56 NO_S3CMD_CFG="WARNING: s3cmd is not configured, run 's3cmd --configure' \
57@@ -224,6 +231,21 @@ if [ ! -x "$DUPLICITY" ]; then
58 exit 1
59 fi
60
61+if [ "`echo ${DEST} | cut -c 1,2`" = "gs" ]; then
62+ DEST_IS_GS=true
63+ GSCMD="$(which gsutil)"
64+ if [ ! -x "$GSCMD" ]; then
65+ echo $NO_GSCMD; GSCMD_AVAIL=false
66+ elif [ ! -f "${HOME}/.boto" ]; then
67+ echo $NO_GSCMD_CFG; GSCMD_AVAIL=false
68+ else
69+ GSCMD_AVAIL=true
70+ GSCMD="${GSCMD}"
71+ fi
72+else
73+ DEST_IS_GS=false
74+fi
75+
76 if [ "`echo ${DEST} | cut -c 1,2`" = "s3" ]; then
77 DEST_IS_S3=true
78 S3CMD="$(which s3cmd)"
79@@ -270,6 +292,8 @@ check_variables ()
80 [[ ${LOGDIR} = "/home/foobar_user_name/logs/test2/" ]] && config_sanity_fail "LOGDIR must be configured"
81 [[ ( ${DEST_IS_S3} = true && (${AWS_ACCESS_KEY_ID} = "foobar_aws_key_id" || ${AWS_SECRET_ACCESS_KEY} = "foobar_aws_access_key" )) ]] && \
82 config_sanity_fail "An s3 DEST has been specified, but AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY have not been configured"
83+ [[ ( ${DEST_IS_GS} = true && (${GS_ACCESS_KEY_ID} = "foobar_gcs_key_id" || ${GS_SECRET_ACCESS_KEY} = "foobar_gcs_secret_id" )) ]] && \
84+ 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"
85 [[ ! -z "$INCEXCFILE" && ! -f $INCEXCFILE ]] && config_sanity_fail "The specified INCEXCFILE $INCEXCFILE does not exists"
86 }
87
88@@ -414,6 +438,13 @@ get_remote_file_size()
89 TMPDEST=`echo ${DEST} | cut -c 6-`
90 SIZE=`du -hs ${TMPDEST} | awk '{print $1}'`
91 ;;
92+ "gs")
93+ FRIENDLY_TYPE_NAME="Google Cloud Storage"
94+ if $GSCMD_AVAIL ; then
95+ TMPDEST=`echo $DEST | sed -e "s/\/*$//" `
96+ SIZE=`gsutil du -hs ${TMPDEST} | awk '{print $1$2}'`
97+ fi
98+ ;;
99 "s3")
100 FRIENDLY_TYPE_NAME="S3"
101 if $S3CMD_AVAIL ; then
102@@ -794,6 +825,8 @@ fi
103
104 unset AWS_ACCESS_KEY_ID
105 unset AWS_SECRET_ACCESS_KEY
106+unset GS_ACCESS_KEY_ID
107+unset GS_SECRET_ACCESS_KEY
108 unset PASSPHRASE
109 unset SIGN_PASSPHRASE
110 unset FTP_PASSWORD