@@ -184,7 +184,7 @@ To run the backup automatically, edit the root crontab.
184184
185185```ini
186186# =================================================================
187- # Configuration for rsync Backup Script v0.30
187+ # Configuration for rsync Backup Script v0.31
188188# =================================================================
189189# !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf)
190190
@@ -216,6 +216,9 @@ BEGIN_SSH_OPTS
216216/root/.ssh/id_ed25519
217217END_SSH_OPTS
218218
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+
219222# The timeout in seconds for rsync operations.
220223RSYNC_TIMEOUT=300
221224
@@ -304,7 +307,7 @@ END_EXCLUDES
304307
305308` ` ` bash
306309#! /bin/bash
307- # ===================== v0.30 - 2025.08.13 ========================
310+ # ===================== v0.31 - 2025.08.13 ========================
308311#
309312# =================================================================
310313# SCRIPT INITIALIZATION & SETUP
@@ -374,9 +377,8 @@ if [ -f "$CONFIG_FILE" ]; then
374377 value=" ${value% \" } " ; value=" ${value# \" } "
375378
376379 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|\
380382 NTFY_ENABLED|DISCORD_ENABLED|NTFY_TOKEN|NTFY_URL|DISCORD_WEBHOOK_URL|\
381383 NTFY_PRIORITY_SUCCESS|NTFY_PRIORITY_WARNING|NTFY_PRIORITY_FAILURE|\
382384 RECYCLE_BIN_ENABLED|RECYCLE_BIN_DIR|RECYCLE_BIN_RETENTION_DAYS)
@@ -435,11 +437,15 @@ if (( ${#SSH_OPTS_ARRAY[@]} > 0 )); then
435437fi
436438
437439RSYNC_BASE_OPTS=(
438- -aR -z --delete --partial --timeout=" ${RSYNC_TIMEOUT:- 300} " --mkpath --noatime
440+ -aR -z --delete --partial --timeout=" ${RSYNC_TIMEOUT:- 300} " --mkpath
439441 --exclude-from=" $EXCLUDE_FILE_TMP "
440442 -e " $SSH_CMD "
441443)
442444
445+ if [[ " ${RSYNC_NOATIME_ENABLED:- false} " == " true" ]]; then
446+ RSYNC_BASE_OPTS+=(--noatime)
447+ fi
448+
443449# Optional: Add bandwidth limit if configured
444450if [[ -n " ${BANDWIDTH_LIMIT_KBPS:- } " && " ${BANDWIDTH_LIMIT_KBPS} " -gt 0 ]]; then
445451 RSYNC_BASE_OPTS+=(--bwlimit=" $BANDWIDTH_LIMIT_KBPS " )
@@ -542,6 +548,20 @@ run_preflight_checks() {
542548 done
543549 if [[ " $check_failed " == " true" ]]; then exit 10; fi
544550 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
545565 if [[ " $test_mode " == " true" ]]; then printf " ${C_BOLD} --- Checking SSH connectivity...${C_RESET} \n" ; fi
546566 # Quick preflight connectivity "ping": short 10s timeout for fail-fast behaviour
547567 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() {
568588 fi
569589 if [[ " $dir " != * " /./" * ]]; then
570590 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
572592 echo " ❌ FATAL: $err_msg "
573593 else
574594 send_notification " ❌ Backup FAILED: ${HOSTNAME} " " x" " ${NTFY_PRIORITY_FAILURE} " " failure" " FATAL: $err_msg "
0 commit comments