diff --git a/README.md b/README.md index c78741f..2a4fd8c 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ To run the backup automatically, edit the root crontab. ```ini # ================================================================= -# Configuration for rsync Backup Script v0.33 +# Configuration for rsync Backup Script v0.34 # ================================================================= # !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf) @@ -310,7 +310,7 @@ END_EXCLUDES ```bash #!/bin/bash -# ===================== v0.33 - 2025.08.15 ======================== +# ===================== v0.34 - 2025.08.15 ======================== # # ================================================================= # SCRIPT INITIALIZATION & SETUP @@ -503,7 +503,8 @@ run_integrity_check() { local DIRS_ARRAY; read -ra DIRS_ARRAY <<< "$BACKUP_DIRS" for dir in "${DIRS_ARRAY[@]}"; do echo "--- Integrity Check: $dir ---" >&2 - LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "$REMOTE_TARGET" 2>> "${LOG_FILE:-/dev/null}" + local relative_path="${dir#*./}" + LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "${REMOTE_TARGET}${relative_path}" 2>> "${LOG_FILE:-/dev/null}" done } parse_stat() { @@ -976,8 +977,7 @@ for dir in "${DIRS_ARRAY[@]}"; do RSYNC_EXIT_CODE=${PIPESTATUS[0]} else RSYNC_OPTS+=(--info=stats2) - nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 - RSYNC_EXIT_CODE=$? + nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 || RSYNC_EXIT_CODE=$? fi cat "$RSYNC_LOG_TMP" >> "$LOG_FILE"; full_rsync_output+=$'\n'"$(<"$RSYNC_LOG_TMP")" rm -f "$RSYNC_LOG_TMP" diff --git a/backup.conf b/backup.conf index 0b95fc0..8284ff0 100644 --- a/backup.conf +++ b/backup.conf @@ -1,5 +1,5 @@ # ================================================================= -# Configuration for rsync Backup Script v0.33 +# Configuration for rsync Backup Script v0.34 # ================================================================= # !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf) diff --git a/backup_script.sh b/backup_script.sh index 5fd7c2f..c4ba2d4 100644 --- a/backup_script.sh +++ b/backup_script.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ===================== v0.33 - 2025.08.15 ======================== +# ===================== v0.34 - 2025.08.15 ======================== # # Example backup.conf: # BACKUP_DIRS="/home/user/test/./ /var/www/./" @@ -223,7 +223,8 @@ run_integrity_check() { local DIRS_ARRAY; read -ra DIRS_ARRAY <<< "$BACKUP_DIRS" for dir in "${DIRS_ARRAY[@]}"; do echo "--- Integrity Check: $dir ---" >&2 - LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "$REMOTE_TARGET" 2>> "${LOG_FILE:-/dev/null}" + local relative_path="${dir#*./}" + LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "${REMOTE_TARGET}${relative_path}" 2>> "${LOG_FILE:-/dev/null}" done } parse_stat() { @@ -696,8 +697,7 @@ for dir in "${DIRS_ARRAY[@]}"; do RSYNC_EXIT_CODE=${PIPESTATUS[0]} else RSYNC_OPTS+=(--info=stats2) - nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 - RSYNC_EXIT_CODE=$? + nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 || RSYNC_EXIT_CODE=$? fi cat "$RSYNC_LOG_TMP" >> "$LOG_FILE"; full_rsync_output+=$'\n'"$(<"$RSYNC_LOG_TMP")" rm -f "$RSYNC_LOG_TMP" diff --git a/backup_script.sh.sha256 b/backup_script.sh.sha256 index fb2c061..e7b8c10 100644 --- a/backup_script.sh.sha256 +++ b/backup_script.sh.sha256 @@ -1 +1 @@ -0326b76d0b48e10bc03c4a3b03a7c647bad2579976d50e04f41a014291a747d6 backup_script.sh +6f2c36b78fae2803420ce49c4052372815af678983596369f6d81e7924175cb0 backup_script.sh diff --git a/clean_backup.conf b/clean_backup.conf index 0a458bb..5907046 100644 --- a/clean_backup.conf +++ b/clean_backup.conf @@ -1,5 +1,4 @@ # --- Source and Destination --- -# List all source directories to back up, separated by spaces. BACKUP_DIRS="/./home/user/ /./var/log/ /./etc/nginx/" BOX_DIR="/home/myvps/"