„monitor_backup_dir.sh“ ändern
This commit is contained in:
parent
536a379064
commit
1251c7e491
|
@ -1,14 +1,15 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
target_dir=/var/borg
|
target_dir=/var/borg
|
||||||
hash_dir=/var/hashes
|
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
|
find ${target_dir}/* -maxdepth 0 -type d | while read line; do
|
||||||
host=$(echo "$line" | awk -F" +|/" '{print $NF}')
|
host=$(echo "$line" | awk -F" +|/" '{print $NF}')
|
||||||
if [[ ! $host =~ ^(lost\+found)$ ]]; then
|
if [[ ! $host =~ ^(lost\+found)$ ]]; then
|
||||||
hash=$(mtree -cxp "$line" | grep -E -- ^\[^\#] | sha256sum)
|
hash=$(mtree -cxp "$line" | grep -E -- ^\[^\#] | sha256sum)
|
||||||
if test -f "${hash_dir}/$host"; then
|
if test -f "${hash_dir}/$host"; then
|
||||||
difference=$(diff ${hash_dir}/$host <(echo "$hash"))
|
if [ "$hash" == "$(head -c99 < "${hash_dir}/${host}")" ]; then
|
||||||
if [ "$difference" == "" ]; 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."
|
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"
|
echo "$mail_body" | mail -s "${host} not backed up!" "$mail_to"
|
||||||
fi
|
fi
|
||||||
|
@ -18,4 +19,4 @@ find ${target_dir}/* -maxdepth 0 -type d | while read line; do
|
||||||
fi
|
fi
|
||||||
echo "$hash" > "${hash_dir}/$host"
|
echo "$hash" > "${hash_dir}/$host"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
Loading…
Reference in New Issue