Skip to content

Commit 56bc494

Browse files
authored
Update README.md
1 parent d269e71 commit 56bc494

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ EXCLUDE_FILE_TMP=$(mktemp)
233233

234234
# --- Securely parse the unified configuration file ---
235235
if [ -f "$CONFIG_FILE" ]; then
236-
# Initialize an empty array for SSH options for robustness
237-
SSH_OPTS_ARR=()
238236
in_exclude_block=false
239237
while IFS= read -r line; do
240238
# Handle the rsync exclusion block
@@ -261,11 +259,6 @@ if [ -f "$CONFIG_FILE" ]; then
261259

262260
# CRITICAL: Assign value as a literal string to prevent code injection
263261
declare "$key"="$value"
264-
265-
# Robustly handle SSH options by converting the string to an array
266-
if [[ "$key" == "SSH_OPTS_STR" ]]; then
267-
read -r -a SSH_OPTS_ARR <<< "$value"
268-
fi
269262
fi
270263
done < "$CONFIG_FILE"
271264
else
@@ -282,7 +275,7 @@ MAX_LOG_SIZE=10485760 # 10 MB in bytes
282275
RSYNC_BASE_OPTS=(
283276
-a -z --delete --partial --timeout=60
284277
--exclude-from="$EXCLUDE_FILE_TMP"
285-
-e "ssh ${SSH_OPTS_ARR[@]}"
278+
-e "ssh ${SSH_OPTS_STR:-}"
286279
)
287280

288281
# =================================================================
@@ -325,7 +318,7 @@ send_notification() {
325318
}
326319

327320
run_integrity_check() {
328-
local rsync_check_opts=(-ainc -c --delete --exclude-from="$EXCLUDE_FILE_TMP" --out-format="%n" -e "ssh ${SSH_OPTS_ARR[@]}")
321+
local rsync_check_opts=(-ainc -c --delete --exclude-from="$EXCLUDE_FILE_TMP" --out-format="%n" -e "ssh ${SSH_OPTS_STR:-}")
329322
LC_ALL=C rsync "${rsync_check_opts[@]}" "$LOCAL_DIR" "$REMOTE_TARGET" 2>> "${LOG_FILE:-/dev/null}"
330323
}
331324

@@ -336,12 +329,10 @@ format_backup_stats() {
336329
local files_created=""
337330
local files_deleted=""
338331

339-
# First, try parsing the machine-readable format from --info=stats2
340332
bytes_transferred=$(echo "$rsync_output" | grep 'Total_transferred_size:' | awk '{print $2}')
341333
files_created=$(echo "$rsync_output" | grep 'Number_of_created_files:' | awk '{print $2}')
342334
files_deleted=$(echo "$rsync_output" | grep 'Number_of_deleted_files:' | awk '{print $2}')
343335

344-
# If parsing failed, fall back to the human-readable --stats format
345336
if [[ -z "$bytes_transferred" && -z "$files_created" && -z "$files_deleted" ]]; then
346337
bytes_transferred=$(echo "$rsync_output" | grep 'Total transferred file size:' | awk '{gsub(/,/, ""); print $5}')
347338
files_created=$(echo "$rsync_output" | grep 'Number of created files:' | awk '{print $5}')
@@ -376,7 +367,7 @@ for cmd in "${REQUIRED_CMDS[@]}"; do
376367
fi
377368
done
378369

379-
if ! ssh "${SSH_OPTS_ARR[@]}" -o BatchMode=yes -o ConnectTimeout=10 "$HETZNER_BOX" 'exit' 2>/dev/null; then
370+
if ! ssh ${SSH_OPTS_STR:-} -o BatchMode=yes -o ConnectTimeout=10 "$HETZNER_BOX" 'exit' 2>/dev/null; then
380371
send_notification "❌ SSH FAILED: ${HOSTNAME}" "x" "high" "failure" "Unable to SSH into $HETZNER_BOX. Check keys and connectivity."
381372
trap - ERR; exit 6
382373
fi

0 commit comments

Comments
 (0)