2
0
Fork 0
main
Ducky 2024-04-01 21:32:53 +01:00
parent 3fd25c3e59
commit 930a21ccca
1 changed files with 23 additions and 1 deletions

View File

@ -179,12 +179,34 @@ function invoke_script() {
exec 3>&1 exec 3>&1
script_output=$("$backup_scripts_dir/$backup_script_filename" 2>&1 | tee /dev/fd/3) script_output=$("$backup_scripts_dir/$backup_script_filename" 2>&1 | tee /dev/fd/3)
echo "$?"
if [[ "$?" == 0 ]]; then
trigger_notify "success" "Backup Successful: $backup_script_name" "$script_output"
else
trigger_notify "error" "Backup Failed: $backup_script_name" "$script_output"
fi
set +o pipefail set +o pipefail
exec 3>&- exec 3>&-
} }
function trigger_notify() {
level="$1"
title="$2"
output="$3"
notify_prog="/usr/local/bin/sh.zio.notify"
if [[ ! -f "$notify_prog" ]]; then
say warning "'$notify_prog' not found. Not sending notification"
else
/usr/local/bin/sh.zio.notify
--invoked-by "sh.zio.backup" \
--level "$level" \
--message '```\\n'"${output//$'\n'/'\\n'}"'\\n```' \
--title "$title"
fi
}
function backup_files() { function backup_files() {
patterns="$1" patterns="$1"
args="${@:2}" args="${@:2}"