Skip to content

Commit 00a8873

Browse files
authored
Merge pull request #35 from buildplan/improved_term_prompts
Added --noatime and RSYNC_TIMEOUT to RSYNC_BASE_OPTS
2 parents b65b314 + 5e77de7 commit 00a8873

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

README.md

Lines changed: 11 additions & 4 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.29
187+
# Configuration for rsync Backup Script v0.30
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
217217
END_SSH_OPTS
218218
219+
# The timeout in seconds for rsync operations.
220+
RSYNC_TIMEOUT=300
221+
219222
# --- Performance ---
220223
# Optional: Limit rsync's bandwidth usage in KiB/s. Leave empty or set to 0 to disable.
221224
# Example: BANDWIDTH_LIMIT_KBPS=5000 (for 5 MB/s)
@@ -301,7 +304,7 @@ END_EXCLUDES
301304
302305
```bash
303306
#!/bin/bash
304-
# ===================== v0.29 - 2025.08.13 ========================
307+
# ===================== v0.30 - 2025.08.13 ========================
305308
#
306309
# =================================================================
307310
# SCRIPT INITIALIZATION & SETUP
@@ -372,7 +375,7 @@ if [ -f "$CONFIG_FILE" ]; then
372375

373376
case "$key" in
374377
BACKUP_DIRS|BOX_DIR|BOX_ADDR|LOG_FILE|LOG_RETENTION_DAYS|\
375-
MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|\
378+
MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|RSYNC_TIMEOUT|\
376379
CHECKSUM_ENABLED|\
377380
NTFY_ENABLED|DISCORD_ENABLED|NTFY_TOKEN|NTFY_URL|DISCORD_WEBHOOK_URL|\
378381
NTFY_PRIORITY_SUCCESS|NTFY_PRIORITY_WARNING|NTFY_PRIORITY_FAILURE|\
@@ -432,7 +435,7 @@ if (( ${#SSH_OPTS_ARRAY[@]} > 0 )); then
432435
fi
433436

434437
RSYNC_BASE_OPTS=(
435-
-aR -z --delete --partial --timeout=60 --mkpath
438+
-aR -z --delete --partial --timeout="${RSYNC_TIMEOUT:-300}" --mkpath --noatime
436439
--exclude-from="$EXCLUDE_FILE_TMP"
437440
-e "$SSH_CMD"
438441
)
@@ -929,6 +932,10 @@ FINAL_MESSAGE=$(printf "%s\n\nSuccessful: %s\nFailed: %s\n\nDuration: %dm %ds" \
929932
"${failed_dirs[*]:-None}" \
930933
$((DURATION / 60)) $((DURATION % 60)))
931934

935+
if [[ ${#FINAL_MESSAGE} -gt 1800 ]]; then
936+
FINAL_MESSAGE=$(printf "%.1800s\n\n[Message truncated, see %s for full details]" "$FINAL_MESSAGE" "$LOG_FILE")
937+
fi
938+
932939
if [[ ${#failed_dirs[@]} -eq 0 ]]; then
933940
log_message "SUCCESS: All backups completed."
934941
if [[ $overall_exit_code -eq 24 ]]; then

backup.conf

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

@@ -31,6 +31,9 @@ BEGIN_SSH_OPTS
3131
/root/.ssh/id_ed25519
3232
END_SSH_OPTS
3333

34+
# The timeout in seconds for rsync operations.
35+
RSYNC_TIMEOUT=300
36+
3437
# --- Performance ---
3538
# Optional: Limit rsync's bandwidth usage in KiB/s. Leave empty or set to 0 to disable.
3639
# Example: BANDWIDTH_LIMIT_KBPS=5000 (for 5 MB/s)

backup_script.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# ===================== v0.29 - 2025.08.13 ========================
2+
# ===================== v0.30 - 2025.08.13 ========================
33
#
44
# Example backup.conf:
55
# BACKUP_DIRS="/home/user/test/./ /var/www/./"
@@ -9,6 +9,7 @@
99
# LOG_RETENTION_DAYS=7
1010
# MAX_LOG_SIZE_MB=10
1111
# BANDWIDTH_LIMIT_KBPS=1000
12+
# RSYNC_TIMEOUT=300
1213
# RECYCLE_BIN_ENABLED=true
1314
# RECYCLE_BIN_DIR="recycle_bin"
1415
# RECYCLE_BIN_RETENTION_DAYS=30
@@ -98,7 +99,7 @@ if [ -f "$CONFIG_FILE" ]; then
9899

99100
case "$key" in
100101
BACKUP_DIRS|BOX_DIR|BOX_ADDR|LOG_FILE|LOG_RETENTION_DAYS|\
101-
MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|\
102+
MAX_LOG_SIZE_MB|BANDWIDTH_LIMIT_KBPS|RSYNC_TIMEOUT|\
102103
CHECKSUM_ENABLED|\
103104
NTFY_ENABLED|DISCORD_ENABLED|NTFY_TOKEN|NTFY_URL|DISCORD_WEBHOOK_URL|\
104105
NTFY_PRIORITY_SUCCESS|NTFY_PRIORITY_WARNING|NTFY_PRIORITY_FAILURE|\
@@ -158,7 +159,7 @@ if (( ${#SSH_OPTS_ARRAY[@]} > 0 )); then
158159
fi
159160

160161
RSYNC_BASE_OPTS=(
161-
-aR -z --delete --partial --timeout=60 --mkpath
162+
-aR -z --delete --partial --timeout="${RSYNC_TIMEOUT:-300}" --mkpath --noatime
162163
--exclude-from="$EXCLUDE_FILE_TMP"
163164
-e "$SSH_CMD"
164165
)
@@ -655,6 +656,10 @@ FINAL_MESSAGE=$(printf "%s\n\nSuccessful: %s\nFailed: %s\n\nDuration: %dm %ds" \
655656
"${failed_dirs[*]:-None}" \
656657
$((DURATION / 60)) $((DURATION % 60)))
657658

659+
if [[ ${#FINAL_MESSAGE} -gt 1800 ]]; then
660+
FINAL_MESSAGE=$(printf "%.1800s\n\n[Message truncated, see %s for full details]" "$FINAL_MESSAGE" "$LOG_FILE")
661+
fi
662+
658663
if [[ ${#failed_dirs[@]} -eq 0 ]]; then
659664
log_message "SUCCESS: All backups completed."
660665
if [[ $overall_exit_code -eq 24 ]]; then

backup_script.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d63902e9e143da4499870cea9813608acd070f466953d29ea80d7c61cfcc0bbf backup_script.sh
1+
192650a55e70472ef23fdea13b0738cc259bdbb66ed10da6b8074131680acc2c backup_script.sh

0 commit comments

Comments
 (0)