6df09021a6555876c80d391f571316fa3d169635

Author
Zertrin <zertrin@gmail.com>
Committer
Zertrin <zertrin@gmail.com>
Date

Message

Fix issue #33 : Allow to specify the s3cmd configuration file

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index 964793aaa310a7159f35e4bee948620791256f5a..0d5fb37c09ce4302310d3c91b32f4d2545c99886 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -43,6 +43,14 @@
 6 AWS_ACCESS_KEY_ID="foobar_aws_key_id"
 7 AWS_SECRET_ACCESS_KEY="foobar_aws_access_key"
 8 
 9+# S3CMD INFORMATION
10+# Most people don't need that, but in some cases 
11+# you may want to specify a custom configuration file
12+# to pass to s3cmd. If so, set the S3CMD_CONF_FILE variable
13+# to the full path of this custom config file.
14+# Per default s3cmd uses ${HOME}/.s3cfg
15+# S3CMD_CONF_FILE='/path/to/your/s3cmd/conf/file'
16+
17 # ENCRYPTION INFORMATION
18 # Do you want your backup to be encrypted? yes/no
19 # If yes, please make sure you specify either PASSPHRASE or GPG_ENC_KEY/GPG_SIGN_KEY
20diff --git a/duplicity-backup.sh b/duplicity-backup.sh
21index 70749110cd25a660a342c6fec5d54ac2e8546360..2caa5362ed065ad658ab546cd074e93f986d142e 100755
22--- a/duplicity-backup.sh
23+++ b/duplicity-backup.sh
24@@ -195,10 +195,18 @@ if  [ "`echo ${DEST} | cut -c 1,2`" = "s3" ]; then
25   S3CMD="$(which s3cmd)"
26   if [ ! -x "$S3CMD" ]; then
27     echo $NO_S3CMD; S3CMD_AVAIL=false
28-  elif [ ! -f "${HOME}/.s3cfg" ]; then
29+  elif [ -z "$S3CMD_CONF_FILE" -a ! -f "${HOME}/.s3cfg" ]; then
30     echo $NO_S3CMD_CFG; S3CMD_AVAIL=false
31+  elif [ ! -z "$S3CMD_CONF_FILE" -a ! -f "$S3CMD_CONF_FILE" ]; then
32+    echo "${S3CMD_CONF_FILE} not found, check S3CMD_CONF_FILE variable in duplicity-backup's configuration!";
33+    echo $NO_S3CMD_CFG;
34+    S3CMD_AVAIL=false
35   else
36     S3CMD_AVAIL=true
37+
38+    if [ ! -z "$S3CMD_CONF_FILE" -a -f "$S3CMD_CONF_FILE" ]; then
39+      S3CMD="${S3CMD} -c ${S3CMD_CONF_FILE}"
40+    fi
41   fi
42 else
43   DEST_IS_S3=false
44@@ -321,7 +329,7 @@ get_remote_file_size()
45     "s3")
46       if $S3CMD_AVAIL ; then
47           TMPDEST=$(echo ${DEST} | cut -c 11-)
48-          SIZE=`s3cmd du -H s3://${TMPDEST} | awk '{print $1}'`
49+          SIZE=`${S3CMD} du -H s3://${TMPDEST} | awk '{print $1}'`
50       else
51           SIZE="s3cmd not installed."
52       fi