@@ -184,7 +184,7 @@ To run the backup automatically, edit the root crontab.
184
184
185
185
```ini
186
186
# =================================================================
187
- # Configuration for rsync Backup Script v0.30
187
+ # Configuration for rsync Backup Script v0.31
188
188
# =================================================================
189
189
# !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf)
190
190
@@ -216,6 +216,9 @@ BEGIN_SSH_OPTS
216
216
/root/.ssh/id_ed25519
217
217
END_SSH_OPTS
218
218
219
+ # Set RSYNC_NOATIME_ENABLED to true for a performance boost if rsync >= 3.3.0. Set to false for older versions (e.g., 3.2.7).
220
+ RSYNC_NOATIME_ENABLED=false
221
+
219
222
# The timeout in seconds for rsync operations.
220
223
RSYNC_TIMEOUT=300
221
224
@@ -304,7 +307,7 @@ END_EXCLUDES
304
307
305
308
` ` ` bash
306
309
#! /bin/bash
307
- # ===================== v0.30 - 2025.08.13 ========================
310
+ # ===================== v0.31 - 2025.08.13 ========================
308
311
#
309
312
# =================================================================
310
313
# SCRIPT INITIALIZATION & SETUP
@@ -374,9 +377,8 @@ if [ -f "$CONFIG_FILE" ]; then
374
377
value=" ${value% \" } " ; value=" ${value# \" } "
375
378
376
379
case " $key " in
377
- BACKUP_DIRS|BOX_DIR|BOX_ADDR|LOG_FILE|LOG_RETENTION_DAYS|\
378
- MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|RSYNC_TIMEOUT|\
379
- CHECKSUM_ENABLED|\
380
+ BACKUP_DIRS|BOX_DIR|BOX_ADDR|LOG_FILE|LOG_RETENTION_DAYS|CHECKSUM_ENABLED|\
381
+ MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|RSYNC_TIMEOUT|RSYNC_NOATIME_ENABLED|\
380
382
NTFY_ENABLED|DISCORD_ENABLED|NTFY_TOKEN|NTFY_URL|DISCORD_WEBHOOK_URL|\
381
383
NTFY_PRIORITY_SUCCESS|NTFY_PRIORITY_WARNING|NTFY_PRIORITY_FAILURE|\
382
384
RECYCLE_BIN_ENABLED|RECYCLE_BIN_DIR|RECYCLE_BIN_RETENTION_DAYS)
@@ -435,11 +437,15 @@ if (( ${#SSH_OPTS_ARRAY[@]} > 0 )); then
435
437
fi
436
438
437
439
RSYNC_BASE_OPTS=(
438
- -aR -z --delete --partial --timeout=" ${RSYNC_TIMEOUT:- 300} " --mkpath --noatime
440
+ -aR -z --delete --partial --timeout=" ${RSYNC_TIMEOUT:- 300} " --mkpath
439
441
--exclude-from=" $EXCLUDE_FILE_TMP "
440
442
-e " $SSH_CMD "
441
443
)
442
444
445
+ if [[ " ${RSYNC_NOATIME_ENABLED:- false} " == " true" ]]; then
446
+ RSYNC_BASE_OPTS+=(--noatime)
447
+ fi
448
+
443
449
# Optional: Add bandwidth limit if configured
444
450
if [[ -n " ${BANDWIDTH_LIMIT_KBPS:- } " && " ${BANDWIDTH_LIMIT_KBPS} " -gt 0 ]]; then
445
451
RSYNC_BASE_OPTS+=(--bwlimit=" $BANDWIDTH_LIMIT_KBPS " )
@@ -542,6 +548,20 @@ run_preflight_checks() {
542
548
done
543
549
if [[ " $check_failed " == " true" ]]; then exit 10; fi
544
550
if [[ " $test_mode " == " true" ]]; then printf " ${C_GREEN} ✅ All required commands are present.${C_RESET} \n" ; fi
551
+ # Check rsync version for --noatime compatibility if the feature is enabled
552
+ if [[ " ${RSYNC_NOATIME_ENABLED:- false} " == " true" ]]; then
553
+ if [[ " $test_mode " == " true" ]]; then printf " ${C_BOLD} --- Checking rsync version for --noatime...${C_RESET} \n" ; fi
554
+ local rsync_version
555
+ rsync_version=$( rsync --version | head -n1 | awk ' {print $3}' )
556
+ local major minor
557
+ IFS=' .' read -r major minor _ <<< " $rsync_version"
558
+ if ! (( major > 3 || (major == 3 && minor >= 3 ) )) ; then
559
+ printf " ${C_RED} ❌ FATAL: RSYNC_NOATIME_ENABLED is true but rsync version %s is too old.${C_RESET} \n" " $rsync_version " >&2
560
+ printf " ${C_DIM} The --noatime option requires rsync version 3.3.0 or newer.${C_RESET} \n" >&2
561
+ exit 10
562
+ fi
563
+ if [[ " $test_mode " == " true" ]]; then printf " ${C_GREEN} ✅ rsync version %s supports --noatime.${C_RESET} \n" " $rsync_version " ; fi
564
+ fi
545
565
if [[ " $test_mode " == " true" ]]; then printf " ${C_BOLD} --- Checking SSH connectivity...${C_RESET} \n" ; fi
546
566
# Quick preflight connectivity "ping": short 10s timeout for fail-fast behaviour
547
567
if ! ssh " ${SSH_OPTS_ARRAY[@]} " -o BatchMode=yes -o ConnectTimeout=10 " $BOX_ADDR " ' exit' 2> /dev/null; then
@@ -568,7 +588,7 @@ run_preflight_checks() {
568
588
fi
569
589
if [[ " $dir " != * " /./" * ]]; then
570
590
local err_msg=" Directory '$dir ' in BACKUP_DIRS is missing the required '/./' syntax."
571
- if [[ " $test_mode " == " true" ]]; then
591
+ if [[ " $test_mode " == " true" ]]; then
572
592
echo " ❌ FATAL: $err_msg "
573
593
else
574
594
send_notification " ❌ Backup FAILED: ${HOSTNAME} " " x" " ${NTFY_PRIORITY_FAILURE} " " failure" " FATAL: $err_msg "
0 commit comments