2
0
Fork 0

sh.zio.backup: add retry for restic command

main
Ducky 2023-08-24 02:25:34 +01:00
parent 30871d9739
commit d1c2189f1a
1 changed files with 23 additions and 6 deletions

View File

@ -76,12 +76,29 @@ function invoke_restic() {
elif [[ $command == "generate" || $command == "self-update" ]]; then
say warning "Unsupported command: $command"
else
"$restic_path" \
--cache-dir "$cache_dir" \
--password-file "$restic_repo_passwd_file" \
--repo "$(cat $restic_repo_file)" \
--retry-lock 1h \
$command $args
attempts=10
attempts_delay=600
while true; do
"$restic_path" \
--cache-dir "$cache_dir" \
--password-file "$restic_repo_passwd_file" \
--repo "$(cat $restic_repo_file)" \
$command $args
if [[ $? == 0 ]]; then
break
else
if [[ $attempts == 0 ]]; then
say warning "Command failed. No attempts left"
break
else
attempts=$((attempts - 1))
say warning "Command failed. Trying again in $attempts_delay seconds ($attempts attempts remaining)..."
sleep $attempts_delay
fi
fi
done
fi
}