2
0
Fork 0
This commit is contained in:
Ducky 2024-04-01 21:26:52 +01:00
parent 73e43624b7
commit bfbf3c128f
2 changed files with 78 additions and 32 deletions

View file

@ -73,32 +73,53 @@ function invoke_restic() {
if [[ -z $command ]]; then
say warning "No command specified. Not running"
break
elif [[ $command == "generate" || $command == "self-update" ]]; then
say warning "Unsupported command: $command"
else
attempts=10
attempts_delay=600
break
fi
while true; do
set -o pipefail
exec 3>&1
"$restic_path" \
--cache-dir "$cache_dir" \
--password-file "$restic_repo_passwd_file" \
--repo "$(cat $restic_repo_file)" \
$command $args
restic_out="$("$restic_path" \
--cache-dir "$cache_dir" \
--password-file "$restic_repo_passwd_file" \
--repo "$(cat $restic_repo_file)" \
$command $args 2>&1 | tee /dev/fd/3)"
#attempts=10
#attempts_delay=600
if [[ $? == 0 ]]; then
break
else
say warning "Command failed."
echo "$restic_out"
/usr/local/bin/sh.zio.notify \
--title "Backup failed" \
--message '```\\n'"${restic_out//$'\n'/'\\n'}"'\\n```' \
--level "warning"
break
#while true; do
#set -o pipefail
#exec 3>&1
#function trigger_ntfy() {
# level="$1"
# title="$2"
# output="$3"
# /usr/local/bin/sh.zio.notify
# --invoked-by "sh.zio.backup" \
# --level "$level" \
# --message '```\\n'"${output//$'\n'/'\\n'}"'\\n```' \
# --title "Backup failed"
#}
#restic_out="$("$restic_path" \
# --cache-dir "$cache_dir" \
# --password-file "$restic_repo_passwd_file" \
# --repo "$(cat $restic_repo_file)" \
# $command $args 2>&1 | tee /dev/fd/3)"
#else
#say warning "Command failed."
#echo "$restic_out"
#/usr/local/bin/sh.zio.notify \
# --title "Backup failed" \
# --message '```\\n'"${restic_out//$'\n'/'\\n'}"'\\n```' \
# --level "warning" \
# --invoked-by "sh.zio.backup"
#trigger_ntfy "warning" "Backup failed: "
#break
#echo "---- THE OUTPUT: $restic_out"
#if [[ $attempts == 0 ]]; then
# say warning "Command failed. No attempts left"
@ -108,12 +129,12 @@ function invoke_restic() {
# say warning "Command failed. Trying again in $attempts_delay seconds ($attempts attempts remaining)..."
# sleep $attempts_delay
#fi
fi
#fi
set +o pipefail
exec 3>&-
done
fi
#set +o pipefail
#exec 3>&-
#done
#fi
}
function invoke_script() {