sh.zio.backup: add retry for restic command
parent
30871d9739
commit
d1c2189f1a
|
@ -76,12 +76,29 @@ function invoke_restic() {
|
||||||
elif [[ $command == "generate" || $command == "self-update" ]]; then
|
elif [[ $command == "generate" || $command == "self-update" ]]; then
|
||||||
say warning "Unsupported command: $command"
|
say warning "Unsupported command: $command"
|
||||||
else
|
else
|
||||||
|
attempts=10
|
||||||
|
attempts_delay=600
|
||||||
|
|
||||||
|
while true; do
|
||||||
"$restic_path" \
|
"$restic_path" \
|
||||||
--cache-dir "$cache_dir" \
|
--cache-dir "$cache_dir" \
|
||||||
--password-file "$restic_repo_passwd_file" \
|
--password-file "$restic_repo_passwd_file" \
|
||||||
--repo "$(cat $restic_repo_file)" \
|
--repo "$(cat $restic_repo_file)" \
|
||||||
--retry-lock 1h \
|
|
||||||
$command $args
|
$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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue