From fba4dc75c36bc5ad8506964cb1ab97124d709331 Mon Sep 17 00:00:00 2001 From: Mathieu Trossevin Date: Wed, 22 Nov 2023 17:56:07 +0100 Subject: [PATCH] fix(IS_EVOBACKUP_EXCLUDE_MOUNT): correctly treat old versions of evobackup This commit fix #150 Prior to this older versions of evobackup without `VERSION=` in them would be treated as not having any exclude whatsoever as the `else` block was only inside of the `if grep -q "^VERSION=" "${evobackup_file}"` block. Now the treatment of old evobackup scripts is done if there isn't a `VERSION=` in the script or if the version is older than 22.12. --- linux/evocheck.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/linux/evocheck.sh b/linux/evocheck.sh index 98db80d..914b93d 100755 --- a/linux/evocheck.sh +++ b/linux/evocheck.sh @@ -606,14 +606,10 @@ check_evobackup_exclude_mount() { # then we verify that every mount is excluded if ! grep -q -- "^\s*--one-file-system" "${evobackup_file}"; then # old releases of evobackups don't have version - if grep -q "^VERSION=" "${evobackup_file}"; then - evobackup_version=$(sed -E -n 's/VERSION="(.*)"/\1/p' "${evobackup_file}") - # versions over 22.12 use a new syntax to exclude rsync files - if dpkg --compare-versions "$evobackup_version" ge 22.12 ; then - sed -En '/RSYNC_EXCLUDES="/,/"/ {s/(RSYNC_EXCLUDES=|")//g;p}' "${evobackup_file}" > "${excludes_file}" - else - grep -- "--exclude " "${evobackup_file}" | grep -E -o "\"[^\"]+\"" | tr -d '"' > "${excludes_file}" - fi + if grep -q "^VERSION=" "${evobackup_file}" && dpkg --compare-versions "$(sed -E -n 's/VERSION="(.*)"/\1/p' "${evobackup_file}")" ge 22.12 ; then + sed -En '/RSYNC_EXCLUDES="/,/"/ {s/(RSYNC_EXCLUDES=|")//g;p}' "${evobackup_file}" > "${excludes_file}" + else + grep -- "--exclude " "${evobackup_file}" | grep -E -o "\"[^\"]+\"" | tr -d '"' > "${excludes_file}" fi not_excluded=$(findmnt --type nfs,nfs4,fuse.sshfs, -o target --noheadings | grep -v -f "${excludes_file}") for mount in ${not_excluded}; do