From 271e8623b45f51808f2342ca21a79f434365fcc6 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Thu, 4 Aug 2022 16:09:30 +0200 Subject: [PATCH] check_evobackup_exclude_mount : skip if --one-file-system is used, and exclude scripts without Rsync command --- CHANGELOG | 4 ++++ evocheck.sh | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 56731ea..0de3763 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- check_evobackup_exclude_mount : skip if --one-file-system is used, and exclude scripts without Rsync command + ## [22.08] - 2022-08-04 ### Fixed diff --git a/evocheck.sh b/evocheck.sh index 02f3c4b..1c37691 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -352,11 +352,18 @@ check_evobackup_exclude_mount() { # shellcheck disable=SC2013 for evobackup_file in $(grep -Eo "/usr/share/scripts/zzz_evobackup.*" /etc/daily.local | grep -v "^#" | awk '{print $1}'); do - grep -- "--exclude " "${evobackup_file}" | grep -E -o "\"[^\"]+\"" | tr -d '"' > "${excludes_file}" - not_excluded=$(mount | grep "type nfs" | awk '{print $3}' | grep -v -f "${excludes_file}") - for mount in ${not_excluded}; do - failed "IS_EVOBACKUP_EXCLUDE_MOUNT" "${mount} is not excluded from ${evobackup_file} backup script" - done + # if the file seems to be a backup script, with an Rsync invocation + if grep -q "^\s*rsync" "${evobackup_file}"; then + # If rsync is not limited by "one-file-system" + # then we verify that every mount is excluded + if ! grep -q -- "^\s*--one-file-system" "${evobackup_file}"; then + grep -- "--exclude " "${evobackup_file}" | grep -E -o "\"[^\"]+\"" | tr -d '"' > "${excludes_file}" + not_excluded=$(findmnt --type nfs,nfs4,fuse.sshfs, -o target --noheadings | grep -v -f "${excludes_file}") + for mount in ${not_excluded}; do + failed "IS_EVOBACKUP_EXCLUDE_MOUNT" "${mount} is not excluded from ${evobackup_file} backup script" + done + fi + fi done rm -rf "${excludes_file}" }