From 6ccf6917e451f013bac07bdbba1d7d39f2e0b9c9 Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 19 Jan 2015 17:17:56 +0000 Subject: [PATCH 1/7] Don't skip source disk use report when INCLIST unconfigured --- duplicity-backup.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index af88800..a545f34 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -366,19 +366,29 @@ get_source_file_size() *) DUEXCFLAG="--exclude-from=-" ;; -esac + esac for exclude in ${EXCLIST[@]}; do DUEXCLIST="${DUEXCLIST}${exclude}\n" done - for include in ${INCLIST[@]} - do - echo -e '"'$DUEXCLIST'"' | \ - du -hs ${DUEXCFLAG} ${include} | \ - awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ - >> ${LOGFILE} - done + # if $INCLIST non zero then itterate through it for df readings, else just df $ROOT + # in both cases consider the excluded directories + if [ ! -z "$INCLIST" ]; then + for include in ${INCLIST[@]} + do + echo -e '"'$DUEXCLIST'"' | \ + du -hs ${DUEXCFLAG} ${include} | \ + awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ + >> ${LOGFILE} + done + else + echo -e '"'$DUEXCLIST'"' | \ + du -hs ${DUEXCFLAG} $ROOT | \ + awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ + >> ${LOGFILE} + fi + echo >> ${LOGFILE} # Restore IFS From 646f8c4036136257a54d8e3a28f9ea6cae49782e Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 19 Jan 2015 18:36:11 +0000 Subject: [PATCH 2/7] Excluded directories were no excluded from source disk usage report - quotes issue --- duplicity-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index a545f34..5404051 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -377,13 +377,13 @@ get_source_file_size() if [ ! -z "$INCLIST" ]; then for include in ${INCLIST[@]} do - echo -e '"'$DUEXCLIST'"' | \ + echo -e "$DUEXCLIST" | \ du -hs ${DUEXCFLAG} ${include} | \ awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ >> ${LOGFILE} done else - echo -e '"'$DUEXCLIST'"' | \ + echo -e "$DUEXCLIST" | \ du -hs ${DUEXCFLAG} $ROOT | \ awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ >> ${LOGFILE} From 01ec946eef81c559b613498ba84d0bda06785efa Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 19 Jan 2015 19:08:23 +0000 Subject: [PATCH 3/7] Correct log reports of file size to disk use, plus some log file formatting cleanups --- duplicity-backup.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 5404051..2d6495b 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -348,7 +348,7 @@ get_lock() get_source_file_size() { - echo "---------[ Source File Size Information ]---------" >> ${LOGFILE} + echo "-----------[ Source Disk Use Information ]-----------" >> ${LOGFILE} # Patches to support spaces in paths- # Remove space as a field separator temporarily @@ -397,7 +397,7 @@ get_source_file_size() get_remote_file_size() { - echo "------[ Destination File Size Information ]------" >> ${LOGFILE} + echo "---------[ Destination Disk Use Information ]--------" >> ${LOGFILE} dest_type=`echo ${DEST} | cut -c 1,2` case $dest_type in @@ -423,7 +423,7 @@ get_remote_file_size() ;; esac - echo "Current Remote Backup File Size: ${SIZE}" >> ${LOGFILE} + echo "Current Remote Backup Disk Usage: ${SIZE}" >> ${LOGFILE} echo >> ${LOGFILE} } @@ -472,7 +472,7 @@ include_exclude() duplicity_cleanup() { - echo "-----------[ Duplicity Cleanup ]-----------" >> ${LOGFILE} + echo "----------------[ Duplicity Cleanup ]----------------" >> ${LOGFILE} if [[ "${CLEAN_UP_TYPE}" != "none" && ! -z ${CLEAN_UP_TYPE} && ! -z ${CLEAN_UP_VARIABLE} ]]; then eval ${ECHO} ${DUPLICITY} ${CLEAN_UP_TYPE} ${CLEAN_UP_VARIABLE} ${STATIC_OPTIONS} --force \ ${ENCRYPT} \ @@ -703,7 +703,7 @@ case "$COMMAND" in read ANSWER if [ "$ANSWER" != "yes" ]; then echo "You said << ${ANSWER} >> so I am exiting now." - echo -e "-------- END --------\n" >> ${LOGFILE} + echo -e "--------------------- END ---------------------\n" >> ${LOGFILE} exit 1 fi @@ -728,7 +728,7 @@ case "$COMMAND" in ${DUPLICITY} ${OPTION} ${VERBOSITY} ${STATIC_OPTIONS} \ $ENCRYPT \ ${DEST} | tee -a ${LOGFILE} - echo -e "-------- END --------\n" >> ${LOGFILE} + echo -e "--------------------- END ---------------------\n" >> ${LOGFILE} ;; "collection-status") @@ -738,7 +738,7 @@ case "$COMMAND" in ${DUPLICITY} ${OPTION} ${VERBOSITY} ${STATIC_OPTIONS} \ $ENCRYPT \ ${DEST} | tee -a ${LOGFILE} - echo -e "-------- END --------\n" >> ${LOGFILE} + echo -e "--------------------- END ---------------------\n" >> ${LOGFILE} ;; "backup") @@ -754,7 +754,7 @@ case "$COMMAND" in ;; esac -echo -e "-------- END DUPLICITY-BACKUP SCRIPT --------\n" >> ${LOGFILE} +echo -e "--------- END DUPLICITY-BACKUP SCRIPT ---------\n" >> ${LOGFILE} email_logfile From 6f5b0dccc8659cd0f733e642421d8d8d1dc8b691 Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 19 Jan 2015 20:13:52 +0000 Subject: [PATCH 4/7] My typo in code comment - du not df --- duplicity-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 2d6495b..accfae5 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -372,7 +372,7 @@ get_source_file_size() DUEXCLIST="${DUEXCLIST}${exclude}\n" done - # if $INCLIST non zero then itterate through it for df readings, else just df $ROOT + # if $INCLIST non zero then itterate through it for du -hs readings, else just du -hs $ROOT # in both cases consider the excluded directories if [ ! -z "$INCLIST" ]; then for include in ${INCLIST[@]} From 2e6e383538333b756a67f67059f6d27cbfbc4548 Mon Sep 17 00:00:00 2001 From: zertrin Date: Wed, 21 Jan 2015 16:29:42 +0100 Subject: [PATCH 5/7] Rework on the pull request to refactor the new code --- duplicity-backup.sh | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index accfae5..4704817 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -357,14 +357,14 @@ get_source_file_size() case `uname` in FreeBSD|Darwin|DragonFly) - DUEXCFLAG="-I -" - ;; - OpenBSD) - echo "WARNING: OpenBSD du does not support exclusion, sizes may be off" >> ${LOGFILE} - DUEXCFLAG="" - ;; - *) - DUEXCFLAG="--exclude-from=-" + DUEXCFLAG="-I -" + ;; + OpenBSD) + echo "WARNING: OpenBSD du does not support exclusion, sizes may be off" >> ${LOGFILE} + DUEXCFLAG="" + ;; + *) + DUEXCFLAG="--exclude-from=-" ;; esac @@ -372,22 +372,19 @@ get_source_file_size() DUEXCLIST="${DUEXCLIST}${exclude}\n" done - # if $INCLIST non zero then itterate through it for du -hs readings, else just du -hs $ROOT - # in both cases consider the excluded directories + # if INCLIST is not set or empty, add ROOT to it to be able to calculate disk usage if [ ! -z "$INCLIST" ]; then - for include in ${INCLIST[@]} - do - echo -e "$DUEXCLIST" | \ - du -hs ${DUEXCFLAG} ${include} | \ - awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ - >> ${LOGFILE} - done + DUINCLIST=($ROOT) else - echo -e "$DUEXCLIST" | \ - du -hs ${DUEXCFLAG} $ROOT | \ - awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ - >> ${LOGFILE} + DUINCLIST=$INCLIST fi + + for include in ${DUINCLIST[@]}; do + echo -e "$DUEXCLIST" | \ + du -hs ${DUEXCFLAG} ${include} | \ + awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \ + >> ${LOGFILE} + done echo >> ${LOGFILE} From ea142128064f51c181d4b151d0b927267c36eb17 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 23 Jan 2015 16:25:51 +0000 Subject: [PATCH 6/7] remove not on -z INCLIST check --- duplicity-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 4704817..f5d91e1 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -373,7 +373,7 @@ get_source_file_size() done # if INCLIST is not set or empty, add ROOT to it to be able to calculate disk usage - if [ ! -z "$INCLIST" ]; then + if [ -z "$INCLIST" ]; then DUINCLIST=($ROOT) else DUINCLIST=$INCLIST From 258e68c95adcca22b41618268b6c4d0009427e53 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 23 Jan 2015 17:02:25 +0000 Subject: [PATCH 7/7] copy whole array rather than one element --- duplicity-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index f5d91e1..57c6bbe 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -376,7 +376,7 @@ get_source_file_size() if [ -z "$INCLIST" ]; then DUINCLIST=($ROOT) else - DUINCLIST=$INCLIST + DUINCLIST=("${INCLIST[@]}") fi for include in ${DUINCLIST[@]}; do