k
This commit is contained in:
+11
-7
@@ -33,7 +33,7 @@ else
|
||||
fi
|
||||
|
||||
# Input Arguments
|
||||
DIRECTORY="$1"
|
||||
DIRECTORY="$1" # Directory to sync
|
||||
if [[ -z "$DIRECTORY" ]]; then
|
||||
echo "Usage: $0 <directory-to-sync> [--dry-run] [VAR=value ...]"
|
||||
exit 1
|
||||
@@ -73,14 +73,16 @@ DELAYED_CONTAINERS=(${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]})
|
||||
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||
# Allow multiple patterns per profile
|
||||
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
|
||||
|
||||
echo "Settings: MAX_RSYNC_PROCS=$MAX_RSYNC_PROCS, BW_LIMIT=$BW_LIMIT, CONTAINERS=${CRITICAL_CONTAINER_NAMES[*]}, EXCLUDES=${EXCLUDE_DIRS[*]}"
|
||||
|
||||
# Dependency check
|
||||
for cmd in rsync ssh ping timeout docker tailscale; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || { echo "Error: Required command '$cmd' is not installed."; exit 1; }
|
||||
command -v "$cmd" >/dev/null 2>&1 || {
|
||||
echo "Error: Required command '$cmd' is not installed."
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
trap 'echo "Script interrupted. Exiting."; exit 130' INT TERM
|
||||
@@ -136,7 +138,9 @@ main() {
|
||||
echo "[$LOCAL_SERVER_NAME] Syncing $DIRECTORY → $REMOTE_SERVER:$DIRECTORY"
|
||||
|
||||
for i in $(seq 1 "$RETRY_COUNT"); do
|
||||
if check_server_online; then break; fi
|
||||
if check_server_online; then
|
||||
break
|
||||
fi
|
||||
echo "Remote $REMOTE_SERVER_NAME down, retrying in $SLEEP seconds..."
|
||||
sleep "$SLEEP"
|
||||
done
|
||||
@@ -156,9 +160,9 @@ main() {
|
||||
--no-whole-file
|
||||
)
|
||||
|
||||
# Apply multiple exclude patterns
|
||||
for pattern in "${EXCLUDE_DIRS[@]}"; do
|
||||
RSYNC_OPTS+=(--exclude="$pattern")
|
||||
# Apply profile-specific excludes
|
||||
for ex in "${EXCLUDE_DIRS[@]}"; do
|
||||
RSYNC_OPTS+=(--exclude="$ex")
|
||||
done
|
||||
|
||||
[ "$DRY_RUN" = true ] && RSYNC_OPTS+=("--dry-run")
|
||||
|
||||
Reference in New Issue
Block a user