Updated exclusion to array

This commit is contained in:
2026-03-21 22:40:25 +00:00
parent bd7d812e94
commit 7db77e6445
2 changed files with 12 additions and 16 deletions
+7 -11
View File
@@ -33,7 +33,7 @@ else
fi
# Input Arguments
DIRECTORY="$1" # Directory to sync
DIRECTORY="$1"
if [[ -z "$DIRECTORY" ]]; then
echo "Usage: $0 <directory-to-sync> [--dry-run] [VAR=value ...]"
exit 1
@@ -73,16 +73,14 @@ 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
@@ -138,9 +136,7 @@ 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
@@ -160,9 +156,9 @@ main() {
--no-whole-file
)
# Apply profile-specific excludes
for ex in "${EXCLUDE_DIRS[@]}"; do
RSYNC_OPTS+=(--exclude="$ex")
# Apply multiple exclude patterns
for pattern in "${EXCLUDE_DIRS[@]}"; do
RSYNC_OPTS+=(--exclude="$pattern")
done
[ "$DRY_RUN" = true ] && RSYNC_OPTS+=("--dry-run")