Skip to content

Commit 524bf66

Browse files
authored
Merge pull request #47 from buildplan/improve_fix
minor improvements
2 parents c400280 + a88e3af commit 524bf66

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ To run the backup automatically, edit the root crontab.
184184
185185
```ini
186186
# =================================================================
187-
# Configuration for rsync Backup Script v0.33
187+
# Configuration for rsync Backup Script v0.34
188188
# =================================================================
189189
# !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf)
190190
@@ -310,7 +310,7 @@ END_EXCLUDES
310310
311311
```bash
312312
#!/bin/bash
313-
# ===================== v0.33 - 2025.08.15 ========================
313+
# ===================== v0.34 - 2025.08.15 ========================
314314
#
315315
# =================================================================
316316
# SCRIPT INITIALIZATION & SETUP
@@ -503,7 +503,8 @@ run_integrity_check() {
503503
local DIRS_ARRAY; read -ra DIRS_ARRAY <<< "$BACKUP_DIRS"
504504
for dir in "${DIRS_ARRAY[@]}"; do
505505
echo "--- Integrity Check: $dir ---" >&2
506-
LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "$REMOTE_TARGET" 2>> "${LOG_FILE:-/dev/null}"
506+
local relative_path="${dir#*./}"
507+
LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "${REMOTE_TARGET}${relative_path}" 2>> "${LOG_FILE:-/dev/null}"
507508
done
508509
}
509510
parse_stat() {
@@ -976,8 +977,7 @@ for dir in "${DIRS_ARRAY[@]}"; do
976977
RSYNC_EXIT_CODE=${PIPESTATUS[0]}
977978
else
978979
RSYNC_OPTS+=(--info=stats2)
979-
nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1
980-
RSYNC_EXIT_CODE=$?
980+
nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 || RSYNC_EXIT_CODE=$?
981981
fi
982982
cat "$RSYNC_LOG_TMP" >> "$LOG_FILE"; full_rsync_output+=$'\n'"$(<"$RSYNC_LOG_TMP")"
983983
rm -f "$RSYNC_LOG_TMP"

backup.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =================================================================
2-
# Configuration for rsync Backup Script v0.33
2+
# Configuration for rsync Backup Script v0.34
33
# =================================================================
44
# !! IMPORTANT !! Set file permissions to 600 (chmod 600 backup.conf)
55

backup_script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===================== v0.33 - 2025.08.15 ========================
2+
# ===================== v0.34 - 2025.08.15 ========================
33
#
44
# Example backup.conf:
55
# BACKUP_DIRS="/home/user/test/./ /var/www/./"
@@ -223,7 +223,8 @@ run_integrity_check() {
223223
local DIRS_ARRAY; read -ra DIRS_ARRAY <<< "$BACKUP_DIRS"
224224
for dir in "${DIRS_ARRAY[@]}"; do
225225
echo "--- Integrity Check: $dir ---" >&2
226-
LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "$REMOTE_TARGET" 2>> "${LOG_FILE:-/dev/null}"
226+
local relative_path="${dir#*./}"
227+
LC_ALL=C rsync "${rsync_check_opts[@]}" "$dir" "${REMOTE_TARGET}${relative_path}" 2>> "${LOG_FILE:-/dev/null}"
227228
done
228229
}
229230
parse_stat() {
@@ -696,8 +697,7 @@ for dir in "${DIRS_ARRAY[@]}"; do
696697
RSYNC_EXIT_CODE=${PIPESTATUS[0]}
697698
else
698699
RSYNC_OPTS+=(--info=stats2)
699-
nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1
700-
RSYNC_EXIT_CODE=$?
700+
nice -n 19 ionice -c 3 rsync "${RSYNC_OPTS[@]}" "$dir" "$REMOTE_TARGET" > "$RSYNC_LOG_TMP" 2>&1 || RSYNC_EXIT_CODE=$?
701701
fi
702702
cat "$RSYNC_LOG_TMP" >> "$LOG_FILE"; full_rsync_output+=$'\n'"$(<"$RSYNC_LOG_TMP")"
703703
rm -f "$RSYNC_LOG_TMP"

backup_script.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0326b76d0b48e10bc03c4a3b03a7c647bad2579976d50e04f41a014291a747d6 backup_script.sh
1+
6f2c36b78fae2803420ce49c4052372815af678983596369f6d81e7924175cb0 backup_script.sh

clean_backup.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# --- Source and Destination ---
2-
# List all source directories to back up, separated by spaces.
32
BACKUP_DIRS="/./home/user/ /./var/log/ /./etc/nginx/"
43
BOX_DIR="/home/myvps/"
54

0 commit comments

Comments
 (0)