f8c4d0cc16dec8c850e77fbd68438d828b363d2e

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

Message

Add duplicity version check to handle deprecation of --include-globbing-filelist (fixes #136)

Diff

 1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 2index 9f92a92e6e547adbf709fe8755c3c3bdc39812a8..c0da563ee03407a01899c062fd52e2fe613b90cd 100755
 3--- a/duplicity-backup.sh
 4+++ b/duplicity-backup.sh
 5@@ -107,6 +107,28 @@ if [ ! -x "${DUPLICITY}" ]; then
 6   exit 1
 7 fi
 8 
 9+DUPLICITY_VERSION=$(${DUPLICITY} --version)
10+DUPLICITY_VERSION=${DUPLICITY_VERSION//[^0-9\.]/}
11+
12+version_compare() {
13+    if [[ $1 =~ ^([0-9]+\.?)+$ && $2 =~ ^([0-9]+\.?)+$ ]]; then
14+        local l=(${1//./ }) r=(${2//./ }) s=${#l[@]}; [[ ${#r[@]} -gt ${#l[@]} ]] && s=${#r[@]}
15+
16+        for i in $(seq 0 $((s - 1))); do
17+            [[ ${l[$i]} -gt ${r[$i]} ]] && return 1
18+            [[ ${l[$i]} -lt ${r[$i]} ]] && return 2
19+        done
20+
21+        return 0
22+    else
23+        echo "Invalid version number given"
24+        exit 1
25+    fi
26+}
27+
28+version_compare "${DUPLICITY_VERSION}" 0.7
29+case $? in 2) LT07=1;; *) LT07=0;; esac
30+
31 version(){
32   # Read the version string from the file VERSION
33   VERSION=$(<VERSION)
34@@ -700,7 +722,11 @@ include_exclude()
35 
36   # Include/Exclude globbing filelist
37   if [ "${INCEXCFILE}" != '' ]; then
38-    TMP=" --include-globbing-filelist '${INCEXCFILE}'"
39+    if [ ${LT07} -eq 1 ]; then
40+      TMP=" --include-globbing-filelist '${INCEXCFILE}'"
41+    else
42+      TMP=" --include-filelist '${INCEXCFILE}'"
43+    fi
44     INCLUDE=${INCLUDE}${TMP}
45   fi
46