Enhanced log. fixed some general inconsistencies
This commit is contained in:
+37
-14
@@ -11,7 +11,8 @@ source "$SCRIPT_DIR/../Master.conf"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Separate the positional directory argument from flag/key=value args
|
||||
# Separate the positional directory argument from flag/key=value args.
|
||||
# Flags and key=value pairs are passed to parse_args — directory is handled here.
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
DIRECTORY=""
|
||||
RAW_ARGS=()
|
||||
@@ -27,23 +28,28 @@ parse_args "${RAW_ARGS[@]}"
|
||||
|
||||
[[ -z "$DIRECTORY" ]] && error "No directory specified. Usage: rsync.sh <dir> [--dry-run] [--log]" && exit 1
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# --- $ICON_GEAR Setup ---
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- $ICON_GEAR Setup ---"
|
||||
|
||||
detect_hosts
|
||||
resolve_remote_ip
|
||||
check_connectivity
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Profile resolution — inferred from the directory basename
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Profile is inferred from the directory basename (lowercased)
|
||||
# e.g. /mnt/user/appdata-Failover/Arrs_Stack → arrs_stack
|
||||
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||
info "Profile: $PROFILE_NAME"
|
||||
info "$ICON_GEAR Loading profile: $PROFILE_NAME"
|
||||
|
||||
# Scalar overrides from profile
|
||||
# Scalar overrides — use profile value if defined, fall back to global default
|
||||
BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT}
|
||||
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||
|
||||
# Array overrides from profile — convert space-separated strings to proper bash arrays
|
||||
# Array overrides — profile strings must be converted to bash arrays before use
|
||||
read -r -a CRITICAL_CONTAINER_NAMES <<< "${PROFILE_CRITICAL_CONTAINER_NAMES[$PROFILE_NAME]:-}"
|
||||
read -r -a DELAYED_CONTAINERS <<< "${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]:-}"
|
||||
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
||||
@@ -51,20 +57,26 @@ read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-
|
||||
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Run
|
||||
# --- $ICON_STOP Containers ---
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "$ICON_RUN Sync Starting"
|
||||
echo "--- $ICON_STOP Containers ---"
|
||||
|
||||
stop_containers
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# --- $ICON_SYNC Transfer ---
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- $ICON_SYNC Transfer ---"
|
||||
echo "Source: $DIRECTORY"
|
||||
echo "Remote: $REMOTE_SERVER:$DIRECTORY"
|
||||
echo "Profile: $PROFILE_NAME"
|
||||
echo ""
|
||||
|
||||
stop_containers
|
||||
|
||||
get_rsync_opts
|
||||
|
||||
# Append excludes
|
||||
# Append profile excludes to rsync options
|
||||
for ex in "${EXCLUDE_DIRS[@]}"; do
|
||||
[[ -n "$ex" ]] && RSYNC_OPTS+=(--exclude="$ex")
|
||||
done
|
||||
@@ -75,8 +87,10 @@ START=$(date +%s)
|
||||
RSYNC_SUCCESS=false
|
||||
|
||||
for i in $(seq 1 "$RETRY_COUNT"); do
|
||||
# dirname "$DIRECTORY" is intentional — rsync recreates the final directory on the remote
|
||||
# e.g. source /mnt/user/Movies → remote receives /mnt/user/Movies (not /mnt/user/Movies/Movies)
|
||||
info "$ICON_RETRY Attempt $i of $RETRY_COUNT..."
|
||||
|
||||
# dirname "$DIRECTORY" is intentional — rsync places the directory itself on the remote
|
||||
# e.g. source /mnt/user/Movies syncs to remote /mnt/user/Movies (not /mnt/user/Movies/Movies)
|
||||
if rsync "${RSYNC_OPTS[@]}" \
|
||||
-e "ssh -i $SSH_KEY -T -o Compression=no -o IPQoS=throughput" \
|
||||
"$DIRECTORY" "root@${REMOTE_SERVER}:$(dirname "$DIRECTORY")/"; then
|
||||
@@ -89,10 +103,19 @@ for i in $(seq 1 "$RETRY_COUNT"); do
|
||||
fi
|
||||
done
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# --- $ICON_RUN Containers ---
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "--- $ICON_RUN Containers ---"
|
||||
|
||||
start_containers
|
||||
|
||||
END=$(date +%s)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# --- $ICON_SUCCESS Summary ---
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "===== SUMMARY ====="
|
||||
echo "Directory: $DIRECTORY"
|
||||
|
||||
Reference in New Issue
Block a user