From 4798873ace02d53f78f5ace20d4b96c7dad7d16f Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Tue, 4 Aug 2020 15:08:21 +0200 Subject: [PATCH] Add check_backupuptodate - Check that /home/backup is not older than 2 days --- CHANGELOG | 6 ++++++ evocheck.sh | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 12c66af..26b1de4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.7.4] - 2020-08-04 + +### Added + +- Add check_backupuptodate - Check that /home/backup is not older than 2 days + ## [6.7.3] - 2020-07-23 ### Added diff --git a/evocheck.sh b/evocheck.sh index 7af41af..dfbad68 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -3,7 +3,7 @@ # EvoCheck # Script to verify compliance of an OpenBSD server powered by Evolix -readonly VERSION="6.7.3" +readonly VERSION="6.7.4" # Disable LANG* @@ -139,7 +139,25 @@ check_uptime(){ fi } -check_backuptodate(){ +check_backupuptodate(){ + backup_dir="/home/backup" + if [ -d "${backup_dir}" ]; then + if [ -n "$(ls -A ${backup_dir})" ]; then + for file in ${backup_dir}/*; do + let "limit = $(date +"%s") - 172800" + updated_at=$(stat -f "%m" "$file") + + if [ -f "$file" ] && [ "$limit" -gt "$updated_at" ]; then + failed "IS_BACKUPUPTODATE" "$file has not been backed up" + test "${VERBOSE}" = 1 || break; + fi + done + else + failed "IS_BACKUPUPTODATE" "${backup_dir}/ is empty" + fi + else + failed "IS_BACKUPUPTODATE" "${backup_dir}/ is missing" + fi } check_gitperms(){ @@ -333,7 +351,7 @@ main() { test "${IS_EVOBACKUP:=1}" = 1 && check_evobackup test "${IS_UPTODATE:=1}" = 1 && check_uptodate test "${IS_UPTIME:=1}" = 1 && check_uptime - test "${IS_BACKUPUPTODATE:=1}" = 1 && check_backuptodate + test "${IS_BACKUPUPTODATE:=1}" = 1 && check_backupuptodate test "${IS_GITPERMS:=1}" = 1 && check_gitperms test "${IS_ADVBASE:=1}" = 1 && check_advbase test "${IS_PREEMPT:=1}" = 1 && check_preempt