From 136f21d272c0167254e8e9bf0a181b1eb68422c5 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 1 Oct 2026 13:00:00 +0100 Subject: [PATCH] Wait for others --- src/backup-wrapper.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backup-wrapper.sh b/src/backup-wrapper.sh index a28f916..b79ebb8 100755 --- a/src/backup-wrapper.sh +++ b/src/backup-wrapper.sh @@ -74,14 +74,18 @@ main() { # Finish every backup before spending the former sleep interval checking. for operation in backup check; do - if [[ $operation == check ]]; then - check_deadline=$(/src/interval.sh deadline "${SLEEP_TIME:-1h}") || return 1 - fi check_duration=$((check_budget / target_count)) if (( check_duration == 0 )); then echo "SLEEP_TIME must allow at least one second per repository." return 1 fi + if [[ $operation == check ]]; then + check_deadline=$(/src/interval.sh deadline "${SLEEP_TIME:-1h}") || return 1 + # Borg can sleep for up to 60 seconds between lock attempts. Give + # every waiter a chance to acquire the released locks before checks. + echo "Waiting 60 seconds for queued backups before repository checks" + sleep 60 || return 1 + fi if [ -n "$BORG_REPO" ]; then execute_script || any_failed=true else @@ -125,7 +129,7 @@ main() { rm -f /health/backup_failed || return 1 # A partial check can finish early. Keep the configured interval between - # backup rounds, counting checks and lock waits toward that interval. + # backup rounds, counting the handoff pause, checks and lock waits toward it. /src/interval.sh wait "$check_deadline" }