From f8c4d0cc16dec8c850e77fbd68438d828b363d2e Mon Sep 17 00:00:00 2001 From: zertrin Date: Sun, 24 Sep 2017 14:17:15 +0800 Subject: [PATCH] Add duplicity version check to handle deprecation of --include-globbing-filelist (fixes #136) --- duplicity-backup.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 9f92a92..c0da563 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -107,6 +107,28 @@ if [ ! -x "${DUPLICITY}" ]; then exit 1 fi +DUPLICITY_VERSION=$(${DUPLICITY} --version) +DUPLICITY_VERSION=${DUPLICITY_VERSION//[^0-9\.]/} + +version_compare() { + if [[ $1 =~ ^([0-9]+\.?)+$ && $2 =~ ^([0-9]+\.?)+$ ]]; then + local l=(${1//./ }) r=(${2//./ }) s=${#l[@]}; [[ ${#r[@]} -gt ${#l[@]} ]] && s=${#r[@]} + + for i in $(seq 0 $((s - 1))); do + [[ ${l[$i]} -gt ${r[$i]} ]] && return 1 + [[ ${l[$i]} -lt ${r[$i]} ]] && return 2 + done + + return 0 + else + echo "Invalid version number given" + exit 1 + fi +} + +version_compare "${DUPLICITY_VERSION}" 0.7 +case $? in 2) LT07=1;; *) LT07=0;; esac + version(){ # Read the version string from the file VERSION VERSION=$(