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