From 6e8539b758a1e479f3b4f6e0b54aa0227356c277 Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 14 Aug 2023 14:15:12 +0100 Subject: [PATCH] Add failure modes and runtime to healthcheck --- backup/backup-script.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backup/backup-script.sh b/backup/backup-script.sh index 38cec94..f1639ae 100644 --- a/backup/backup-script.sh +++ b/backup/backup-script.sh @@ -2,6 +2,10 @@ . /etc/backup.conf +if [ ! -z "$HEALTHCHECK_URL" ]; then + curl -L $HEALTHCHECK_URL + '/start' +fi + # some helpers and error handling: info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM @@ -57,13 +61,14 @@ global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit )) if [ ${global_exit} -eq 0 ]; then info "Backup, Prune, and Compact finished successfully" - if [ ! -z "$HEALTHCHECK_URL" ]; then - curl -L $HEALTHCHECK_URL - fi elif [ ${global_exit} -eq 1 ]; then info "Backup, Prune, and/or Compact finished with warnings" else info "Backup, Prune, and/or Compact finished with errors" fi +if [ ! -z "$HEALTHCHECK_URL" ]; then + curl -L $HEALTHCHECK_URL + "/{$global_exit}" +fi + exit ${global_exit} \ No newline at end of file