@@ -233,8 +233,6 @@ EXCLUDE_FILE_TMP=$(mktemp)
233
233
234
234
# --- Securely parse the unified configuration file ---
235
235
if [ -f " $CONFIG_FILE " ]; then
236
- # Initialize an empty array for SSH options for robustness
237
- SSH_OPTS_ARR=()
238
236
in_exclude_block=false
239
237
while IFS= read -r line; do
240
238
# Handle the rsync exclusion block
@@ -261,11 +259,6 @@ if [ -f "$CONFIG_FILE" ]; then
261
259
262
260
# CRITICAL: Assign value as a literal string to prevent code injection
263
261
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
269
262
fi
270
263
done < " $CONFIG_FILE "
271
264
else
@@ -282,7 +275,7 @@ MAX_LOG_SIZE=10485760 # 10 MB in bytes
282
275
RSYNC_BASE_OPTS= (
283
276
-a -z --delete --partial --timeout=60
284
277
--exclude-from=" $EXCLUDE_FILE_TMP "
285
- -e " ssh ${SSH_OPTS_ARR[@] } "
278
+ -e " ssh ${SSH_OPTS_STR :- } "
286
279
)
287
280
288
281
# =================================================================
@@ -325,7 +318,7 @@ send_notification() {
325
318
}
326
319
327
320
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 :- } " )
329
322
LC_ALL=C rsync " ${rsync_check_opts[@]} " " $LOCAL_DIR " " $REMOTE_TARGET " 2>> " ${LOG_FILE:-/ dev/ null} "
330
323
}
331
324
@@ -336,12 +329,10 @@ format_backup_stats() {
336
329
local files_created=" "
337
330
local files_deleted=" "
338
331
339
- # First, try parsing the machine-readable format from --info=stats2
340
332
bytes_transferred=$( echo " $rsync_output " | grep ' Total_transferred_size:' | awk ' {print $2}' )
341
333
files_created=$( echo " $rsync_output " | grep ' Number_of_created_files:' | awk ' {print $2}' )
342
334
files_deleted=$( echo " $rsync_output " | grep ' Number_of_deleted_files:' | awk ' {print $2}' )
343
335
344
- # If parsing failed, fall back to the human-readable --stats format
345
336
if [[ -z " $bytes_transferred " && -z " $files_created " && -z " $files_deleted " ]]; then
346
337
bytes_transferred=$( echo " $rsync_output " | grep ' Total transferred file size:' | awk ' {gsub(/,/, ""); print $5}' )
347
338
files_created=$( echo " $rsync_output " | grep ' Number of created files:' | awk ' {print $5}' )
@@ -376,7 +367,7 @@ for cmd in "${REQUIRED_CMDS[@]}"; do
376
367
fi
377
368
done
378
369
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
380
371
send_notification " ❌ SSH FAILED: ${HOSTNAME} " " x" " high" " failure" " Unable to SSH into $HETZNER_BOX . Check keys and connectivity."
381
372
trap - ERR; exit 6
382
373
fi
0 commit comments