1
0
Fork 0

Restructure directory layout

To make this better than the unorganized mess it used to be.
This commit is contained in:
Luca Beltrame 2021-01-03 15:26:29 +01:00
parent 58a36ed632
commit c4f7279f2e
Signed by: einar
GPG key ID: 4707F46E9EC72DEC
25 changed files with 0 additions and 727 deletions

45
sysadmin/borg_check_last.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/bash
# SPDX-License_identifier: BSD-3-Clause
# Script to check the last known date of the backup and warn if too old
# Requires jq and yq
set -e
set -o nounset
set -o pipefail
mailto="root"
fromname="yournamehere"
mailfrom="yournamehere <yourmail>"
max_days=7
last_bak=$(borgmatic list --last 1 --format "{end} {NEWLINE}" --successful --json | \
jq '.[].archives | sort_by(.end)[].end | gsub("\\.000000$"; "Z") | fromdate')
repository_name=$(yq -r '.location.repositories[0]' /etc/borgmatic/config.yaml)
current=$(date +%s)
difference="$(( current - last_bak ))"
diff_days="$(( difference / (3600 * 24) ))"
host_name=$(hostname)
if (( diff_days > max_days ));
then
sendmail "$mailto" <<EOF
From: $mailfrom
To: $fromname <$mailto>
Subject:[borgbackup] Warning: backup older than $diff_days days.
Hello,
This is an automated message sent from $host_name.
The backup in $repository_name has not been updated in more than $max_days
days. It is advisable to check for errors or disabled services.
--
Automated report system
EOF
fi