From f6ebb9a0f0e9280951581bfacc1c3f00a6709fae Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Sat, 22 Feb 2025 17:00:37 +1100 Subject: [PATCH] Made backup util check if services are online and skip if not running --- deploy/db/backup.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deploy/db/backup.sh b/deploy/db/backup.sh index ea89236..206c96c 100755 --- a/deploy/db/backup.sh +++ b/deploy/db/backup.sh @@ -48,9 +48,13 @@ fi DB_FILE="${DB_FILES[0]}" DB_VER=$(basename "$DB_FILE" .db) -# Send SIGUSR1 to trigger maintenance mode +# Send SIGUSR1 to trigger maintenance mode only for active services +declare -a ACTIVE_PORTS=() for PORT in "${PORTS[@]}"; do - sudo systemctl kill -s SIGUSR1 "$SERVICE_NAME@$PORT.service" + if systemctl is-active --quiet "$SERVICE_NAME@$PORT.service"; then + sudo systemctl kill -s SIGUSR1 "$SERVICE_NAME@$PORT.service" + ACTIVE_PORTS+=("$PORT") + fi done trap release_maintenance EXIT @@ -85,7 +89,7 @@ check_logs() { } # Check logs for each service -for PORT in "${PORTS[@]}"; do +for PORT in "${ACTIVE_PORTS[@]}"; do check_logs "$PORT" done