8c1af2145d55895a5360ebfc846c7a62001f49dd

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

Message

Merge pull request #85 from phillxnet/s3cmd-config-report

Improve reporting on s3cmd state and make disk use log report formats consistent, and add type to destination report

Diff

 1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 2index 3b69115414bbfd95d539cd7fbb7c3a58796d3606..4447d64bfb6f8e952f7198c186516b990bfde27d 100755
 3--- a/duplicity-backup.sh
 4+++ b/duplicity-backup.sh
 5@@ -212,7 +212,7 @@ elif [ "$ENCRYPTION" = "no" ]; then
 6   ENCRYPT="--no-encryption"
 7 fi
 8 
 9-NO_S3CMD="WARNING: s3cmd is not installed, remote file \
10+NO_S3CMD="WARNING: s3cmd no found in PATH, remote file \
11 size information unavailable."
12 NO_S3CMD_CFG="WARNING: s3cmd is not configured, run 's3cmd --configure' \
13 in order to retrieve remote file size information. Remote file \
14@@ -230,15 +230,18 @@ if  [ "`echo ${DEST} | cut -c 1,2`" = "s3" ]; then
15   if [ ! -x "$S3CMD" ]; then
16     echo $NO_S3CMD; S3CMD_AVAIL=false
17   elif [ -z "$S3CMD_CONF_FILE" -a ! -f "${HOME}/.s3cfg" ]; then
18+    S3CMD_CONF_FOUND=false
19     echo $NO_S3CMD_CFG; S3CMD_AVAIL=false
20   elif [ ! -z "$S3CMD_CONF_FILE" -a ! -f "$S3CMD_CONF_FILE" ]; then
21+    S3CMD_CONF_FOUND=false
22     echo "${S3CMD_CONF_FILE} not found, check S3CMD_CONF_FILE variable in duplicity-backup's configuration!";
23     echo $NO_S3CMD_CFG;
24     S3CMD_AVAIL=false
25-  else
26+  else    
27     S3CMD_AVAIL=true
28-
29+    S3CMD_CONF_FOUND=true
30     if [ ! -z "$S3CMD_CONF_FILE" -a -f "$S3CMD_CONF_FILE" ]; then
31+      # if conf file specified and it exists then add it to the command line for s3cmd
32       S3CMD="${S3CMD} -c ${S3CMD_CONF_FILE}"
33     fi
34   fi
35@@ -395,14 +398,16 @@ get_source_file_size()
36 get_remote_file_size()
37 {
38   echo "---------[ Destination Disk Use Information ]--------" >> ${LOGFILE}
39-
40+  FRIENDLY_TYPE_NAME=""
41   dest_type=`echo ${DEST} | cut -c 1,2`
42   case $dest_type in
43     "fi")
44+      FRIENDLY_TYPE_NAME="File"
45       TMPDEST=`echo ${DEST} | cut -c 6-`
46       SIZE=`du -hs ${TMPDEST} | awk '{print $1}'`
47     ;;
48     "s3")
49+      FRIENDLY_TYPE_NAME="S3"
50       if $S3CMD_AVAIL ; then
51           TMPDEST=$(echo ${DEST} | cut -c 11-)
52           dest_scheme=$(echo ${DEST} | cut -f -1 -d :)
53@@ -412,15 +417,21 @@ get_remote_file_size()
54           fi
55           SIZE=`${S3CMD} du -H s3://${TMPDEST} | awk '{print $1}'`
56       else
57-          SIZE="s3cmd not installed."
58+          if ! $S3CMD_CONF_FOUND ; then
59+              SIZE="-s3cmd config not found-"
60+          else
61+              SIZE="-s3cmd not found in PATH-"
62+          fi
63       fi
64     ;;
65     *)
66-      SIZE="unsupported by backend"
67+      # cover all so just grab first 4 chars from DEST
68+      FRIENDLY_TYPE_NAME=`echo ${DEST} | cut -c 1,4`
69+      SIZE="unsupported on"
70     ;;
71   esac
72 
73-  echo "Current Remote Backup Disk Usage: ${SIZE}" >> ${LOGFILE}
74+  echo -e ""$SIZE"\t"$FRIENDLY_TYPE_NAME" type backend" >> ${LOGFILE}
75   echo >> ${LOGFILE}
76 }
77