mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 13:46:59 +01:00
Add alert when backup takes a long time
This commit is contained in:
parent
f318e42f8c
commit
f778bfb44e
4 changed files with 29 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
touch /backups/backup-ongoing
|
||||||
|
|
||||||
REPOSITORY=ssh://backup@phf.ddns.net:2222/./backup
|
REPOSITORY=ssh://backup@phf.ddns.net:2222/./backup
|
||||||
|
|
||||||
export BORG_PASSPHRASE='{{backup_borg_passphrase}}'
|
export BORG_PASSPHRASE='{{backup_borg_passphrase}}'
|
||||||
|
|
@ -53,6 +55,7 @@ borg prune -v --list ${REPOSITORY} --prefix '{hostname}-' \
|
||||||
# Unset the password
|
# Unset the password
|
||||||
export BORG_PASSPHRASE=""
|
export BORG_PASSPHRASE=""
|
||||||
|
|
||||||
|
rm -f /backups/backup-ongoing
|
||||||
touch /backups/backup-ok
|
touch /backups/backup-ok
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
17
roles/monit/files/checkBackupStatus.sh
Executable file
17
roles/monit/files/checkBackupStatus.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ONGOING_FILE="/backups/backup-ongoing"
|
||||||
|
|
||||||
|
if [ -f "$ONGOING_FILE" ]
|
||||||
|
then
|
||||||
|
if test `find "$ONGOING_FILE" -mmin +1`
|
||||||
|
then
|
||||||
|
LAST_MODIFICATION_HOURS=`expr "$(($(date +%s) - $(date +%s -r $ONGOING_FILE)))" / 3600`
|
||||||
|
echo "Backup not finished after more than $LAST_MODIFICATION_HOURS hours"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -6,6 +6,11 @@
|
||||||
name: monit.service
|
name: monit.service
|
||||||
state: started
|
state: started
|
||||||
enabled: True
|
enabled: True
|
||||||
|
- name: Create fullBackup.sh
|
||||||
|
copy:
|
||||||
|
src: checkBackupStatus.sh
|
||||||
|
dest: /usr/local/bin/checkBackupStatus.sh
|
||||||
|
mode: 0700
|
||||||
- name: Copy monit config
|
- name: Copy monit config
|
||||||
template:
|
template:
|
||||||
src: monitrc
|
src: monitrc
|
||||||
|
|
|
||||||
|
|
@ -310,10 +310,12 @@ check system $HOST
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
check file daily-backup with path /backups/backup-ok
|
check file daily-backup-done with path /backups/backup-ok
|
||||||
if timestamp > 25 hours then alert
|
|
||||||
if changed timestamp then alert
|
if changed timestamp then alert
|
||||||
|
|
||||||
|
check program checkBackupStatus with path /usr/local/bin/checkBackupStatus.sh
|
||||||
|
if status != 0 then alert
|
||||||
|
|
||||||
check host home-ssh with address phf.ddns.net
|
check host home-ssh with address phf.ddns.net
|
||||||
if failed port 2222 protocol ssh with timeout 20 seconds then alert
|
if failed port 2222 protocol ssh with timeout 20 seconds then alert
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue