From 1251c7e4912fa51ea692069a1aa50ea2d36fd052 Mon Sep 17 00:00:00 2001 From: Michael Clemens Date: Thu, 1 Apr 2021 18:28:43 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=9Emonitor=5Fbackup=5Fdir.sh=E2=80=9C=20?= =?UTF-8?q?=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitor_backup_dir.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitor_backup_dir.sh b/monitor_backup_dir.sh index f6bfb4d..579d4ab 100644 --- a/monitor_backup_dir.sh +++ b/monitor_backup_dir.sh @@ -1,14 +1,15 @@ +#!/usr/bin/bash + target_dir=/var/borg hash_dir=/var/hashes -mail_to="xxx@xxxx.xxx" +mail_to="xxxxx@xxxx.xxx" find ${target_dir}/* -maxdepth 0 -type d | while read line; do host=$(echo "$line" | awk -F" +|/" '{print $NF}') if [[ ! $host =~ ^(lost\+found)$ ]]; then hash=$(mtree -cxp "$line" | grep -E -- ^\[^\#] | sha256sum) if test -f "${hash_dir}/$host"; then - difference=$(diff ${hash_dir}/$host <(echo "$hash")) - if [ "$difference" == "" ]; then + if [ "$hash" == "$(head -c99 < "${hash_dir}/${host}")" ]; then mail_body="The host ${host} was not backed up since the last check. Please forward this mail to the owner of the affected system." echo "$mail_body" | mail -s "${host} not backed up!" "$mail_to" fi @@ -18,4 +19,4 @@ find ${target_dir}/* -maxdepth 0 -type d | while read line; do fi echo "$hash" > "${hash_dir}/$host" fi -done +done \ No newline at end of file