From a749d24901126bc4761f96cee4a27323876bf715 Mon Sep 17 00:00:00 2001 From: Matt Dirba Date: Fri, 10 Apr 2015 15:26:28 -0500 Subject: [PATCH 1/3] Add support for getting size of remote disk connected via ssh --- duplicity-backup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 3b69115..44bab45 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -398,6 +398,12 @@ get_remote_file_size() dest_type=`echo ${DEST} | cut -c 1,2` case $dest_type in + "ss") + TMPDEST="${DEST#*://*/}" + TMPDEST="${DEST%/${TMPDEST}}" + ssh_opt=`echo $STATIC_OPTIONS |perl -ne 'print "-i $1" if (/IdentityFile= + SIZE=`${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} du -hs ${DEST#${TMPDEST}/ + ;; "fi") TMPDEST=`echo ${DEST} | cut -c 6-` SIZE=`du -hs ${TMPDEST} | awk '{print $1}'` From 20ded180e8cd53a3c03c71456ade9cc8a9a72183 Mon Sep 17 00:00:00 2001 From: Matt Dirba Date: Mon, 13 Apr 2015 17:13:08 -0500 Subject: [PATCH 2/3] Appending usage information to EMAIL_SUBJECT modified: duplicity-backup.sh --- duplicity-backup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 duplicity-backup.sh diff --git a/duplicity-backup.sh b/duplicity-backup.sh old mode 100755 new mode 100644 index 44bab45..58eb713 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -401,8 +401,10 @@ get_remote_file_size() "ss") TMPDEST="${DEST#*://*/}" TMPDEST="${DEST%/${TMPDEST}}" - ssh_opt=`echo $STATIC_OPTIONS |perl -ne 'print "-i $1" if (/IdentityFile= - SIZE=`${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} du -hs ${DEST#${TMPDEST}/ + ssh_opt=`echo $STATIC_OPTIONS |perl -ne 'print "-i $1" if (/IdentityFile="?([^"]*)/);'` + + SIZE=`${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} du -hs ${DEST#${TMPDEST}/} | awk '{print $1}'` 2>> ${LOGFILE} + EMAIL_SUBJECT="$EMAIL_SUBJECT $SIZE `${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} df -hP ${DEST#${TMPDEST}/} | awk '{tmp=$5 " used"}END{print tmp}'`" 2>> ${LOGFILE} ;; "fi") TMPDEST=`echo ${DEST} | cut -c 6-` From c8d249da189a0b449ece2c5a280d3f8c047e9363 Mon Sep 17 00:00:00 2001 From: Matt Dirba Date: Fri, 17 Apr 2015 08:54:36 -0500 Subject: [PATCH 3/3] removed perl dependancy --- duplicity-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 58eb713..4f067ed 100644 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -401,7 +401,7 @@ get_remote_file_size() "ss") TMPDEST="${DEST#*://*/}" TMPDEST="${DEST%/${TMPDEST}}" - ssh_opt=`echo $STATIC_OPTIONS |perl -ne 'print "-i $1" if (/IdentityFile="?([^"]*)/);'` + ssh_opt=`echo $STATIC_OPTIONS |awk -vo="--ssh-options=" '{s=index($0,o); if (s) {s=substr($0,s+length(o)); m=substr(s,0,1); for (i=2; i < length(s); i++) { if (substr(s,i,1) == m && substr(s,i-1,1) != "\\") break; } print substr(s,2,i-2)}}'` SIZE=`${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} du -hs ${DEST#${TMPDEST}/} | awk '{print $1}'` 2>> ${LOGFILE} EMAIL_SUBJECT="$EMAIL_SUBJECT $SIZE `${TMPDEST%://*} ${ssh_opt} ${TMPDEST#*//} df -hP ${DEST#${TMPDEST}/} | awk '{tmp=$5 " used"}END{print tmp}'`" 2>> ${LOGFILE}