add RANDOM_DELAY_SECONDS
This commit is contained in:
1 parent
84b9dea598
commit
8e9b639ee5
2 files changed
+17
-1
No files matched your search
@@ -4,6 +4,17 @@
|
||||
# Exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
|
||||
# --- Optional Random Delay ---
|
||||
# If RANDOM_DELAY_SECONDS is set, sleep for a random duration up to its value
|
||||
# to prevent a "thundering herd" of backups from multiple hosts.
|
||||
if [ -n "$RANDOM_DELAY_SECONDS" ] && [ "$RANDOM_DELAY_SECONDS" -gt 0 ]; then
|
||||
# Sanitize the variable to ensure it's a number
|
||||
DELAY=${RANDOM_DELAY_SECONDS//\"/}
|
||||
SLEEP_TIME=$((RANDOM % DELAY))
|
||||
echo "$(date): Starting random delay of ${SLEEP_TIME}s (max ${DELAY}s)..."
|
||||
sleep ${SLEEP_TIME}
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------
|
||||
# 1. VALIDATION (Ensure Executor Variables Are Set)
|
||||
# ----------------------------------------------------
|
||||
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
# --- 1. CRON SCHEDULING ---
|
||||
# Defines WHEN the entire backup script (backup, prune, check) will run.
|
||||
# Example: "0 0,12 * * *" runs at 00:00 and 12:00 daily
|
||||
- CRON_SCHEDULE="0 0,12 * * *"
|
||||
- CRON_SCHEDULE="0 */12 * * *"
|
||||
|
||||
# --- 2. RUSTIC CORE SETTINGS ---
|
||||
# CRITICAL: Repository Encryption Password
|
||||
@@ -28,6 +28,11 @@ services:
|
||||
- AWS_SECRET_ACCESS_KEY="YOUR_SECRET_KEY"
|
||||
|
||||
# --- 4. EXECUTOR SETTINGS (Used by backup.sh) ---
|
||||
# Optional: Max random delay in seconds to wait before starting the backup.
|
||||
# This helps distribute the load if many containers start at the same time.
|
||||
# Example: 3600 will make the script wait 0-59 minutes before running.
|
||||
- RANDOM_DELAY_SECONDS=3600
|
||||
|
||||
# Paths to backup (space-separated list). Must match the volume mount source.
|
||||
- BACKUP_PATHS="/data/volumes/"
|
||||
|
||||
|
||||
Reference in new issue
Block a user