2e6e383538333b756a67f67059f6d27cbfbc4548

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

Message

Rework on the pull request to refactor the new code

Diff

 1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 2index accfae5dad672ab85cff923bb5bc74af75cb5e40..4704817c22a8334cf942e7138b673352ee56a5ee 100755
 3--- a/duplicity-backup.sh
 4+++ b/duplicity-backup.sh
 5@@ -357,14 +357,14 @@ get_source_file_size()
 6 
 7   case `uname` in
 8     FreeBSD|Darwin|DragonFly)
 9-     DUEXCFLAG="-I -"
10-     ;;
11-   OpenBSD)
12-     echo "WARNING: OpenBSD du does not support exclusion, sizes may be off" >> ${LOGFILE}
13-     DUEXCFLAG=""
14-     ;;
15-   *)
16-    DUEXCFLAG="--exclude-from=-"
17+      DUEXCFLAG="-I -"
18+      ;;
19+    OpenBSD)
20+      echo "WARNING: OpenBSD du does not support exclusion, sizes may be off" >> ${LOGFILE}
21+      DUEXCFLAG=""
22+      ;;
23+    *)
24+      DUEXCFLAG="--exclude-from=-"
25     ;;
26   esac
27 
28@@ -372,22 +372,19 @@ get_source_file_size()
29     DUEXCLIST="${DUEXCLIST}${exclude}\n"
30   done
31 
32-  # if $INCLIST non zero then itterate through it for du -hs readings, else just du -hs $ROOT
33-  # in both cases consider the excluded directories
34+  # if INCLIST is not set or empty, add ROOT to it to be able to calculate disk usage
35   if [ ! -z "$INCLIST" ]; then
36-    for include in ${INCLIST[@]}
37-      do
38-        echo -e "$DUEXCLIST" | \
39-        du -hs ${DUEXCFLAG} ${include} | \
40-        awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \
41-        >> ${LOGFILE}
42-      done
43+    DUINCLIST=($ROOT)
44   else
45-    echo -e "$DUEXCLIST" | \
46-    du -hs ${DUEXCFLAG} $ROOT | \
47-    awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \
48-    >> ${LOGFILE}
49+    DUINCLIST=$INCLIST
50   fi
51+
52+  for include in ${DUINCLIST[@]}; do
53+      echo -e "$DUEXCLIST" | \
54+      du -hs ${DUEXCFLAG} ${include} | \
55+      awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \
56+      >> ${LOGFILE}
57+  done
58   
59   echo >> ${LOGFILE}
60