From 43d09c3ba179d8d1ca521eef118af8f798763916 Mon Sep 17 00:00:00 2001 From: Alexis Ben Miloud--Josselin Date: Mon, 29 Nov 2021 18:26:47 +0100 Subject: [PATCH 1/2] IS_BACKUPUPTODATE Check all files Check time of last data modification of all files under $backup_dir. That will include files like $backup_dir/mysql/dump.sql.gz --- evocheck.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index b7cd83d..6a01238 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -716,12 +716,11 @@ check_backupuptodate() { backup_dir="/home/backup" if [ -d "${backup_dir}" ]; then if [ -n "$(ls -A ${backup_dir})" ]; then - # shellcheck disable=SC2231 - for file in ${backup_dir}/*; do + find "${backup_dir}" -type f | while read -r file; do limit=$(date +"%s" -d "now - 2 day") updated_at=$(stat -c "%Y" "$file") - if [ -f "$file" ] && [ "$limit" -gt "$updated_at" ]; then + if [ "$limit" -gt "$updated_at" ]; then failed "IS_BACKUPUPTODATE" "$file has not been backed up" test "${VERBOSE}" = 1 || break; fi From 5adfdcc614862e2b3840888f146a9401ca06980a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Mon, 6 Jun 2022 14:58:12 +0200 Subject: [PATCH 2/2] Add comment to explain why looking for all files --- evocheck.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evocheck.sh b/evocheck.sh index 6a01238..f4ec27b 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -716,6 +716,8 @@ check_backupuptodate() { backup_dir="/home/backup" if [ -d "${backup_dir}" ]; then if [ -n "$(ls -A ${backup_dir})" ]; then + # Look for all files, including subdirectories. + # If this turns out to be problematic, we can go back to first level only, with --max-depth=1 find "${backup_dir}" -type f | while read -r file; do limit=$(date +"%s" -d "now - 2 day") updated_at=$(stat -c "%Y" "$file")