Skip to content

Commit 5b20444

Browse files
authored
Merge pull request #21 from buildplan/fix_performence_tuning
Fix performence tuning and verbose flag
2 parents f90225c + 5505029 commit 5b20444

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

restic-backup.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ NICE_LEVEL="19"
4949
# IOnice class (1=real-time, 2=best-effort, 3=idle)
5050
IONICE_CLASS="3"
5151

52-
# Limit the number of concurrent file-reading threads (I/O). Leave blank to disable.
53-
LIMIT_THREADS=""
54-
5552
# Limit the upload speed in KiB/s (e.g., 5000 for ~5MB/s). Leave blank to disable.
5653
LIMIT_UPLOAD=""
5754

@@ -61,6 +58,10 @@ GOMAXPROCS_LIMIT=""
6158
# Limit the number of concurrent SFTP connections (e.g., 5). Leave blank for default.
6259
SFTP_CONNECTIONS=""
6360

61+
# Limit how many files are read at the same time during a backup (e.g., 2).
62+
# This is the --read-concurrency flag. Leave blank for default.
63+
READ_CONCURRENCY=""
64+
6465
# --- Logging ---
6566
LOG_FILE="/var/log/restic-backup.log"
6667
LOG_LEVEL="1" # 0=quiet, 1=normal, 2=verbose, 3=very verbose

restic-backup.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env bash
22

33
# =================================================================
4-
# Restic Backup Script v0.34 - 2025.09.27
4+
# Restic Backup Script v0.35 - 2025.09.28
55
# =================================================================
66

77
set -euo pipefail
88
umask 077
99

1010
# --- Script Constants ---
11-
SCRIPT_VERSION="0.34"
11+
SCRIPT_VERSION="0.35"
1212
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
1313
CONFIG_FILE="${SCRIPT_DIR}/restic-backup.conf"
1414
LOCK_FILE="/tmp/restic-backup.lock"
@@ -298,15 +298,13 @@ handle_crash() {
298298

299299
build_backup_command() {
300300
local cmd=(restic)
301-
[ "${LOG_LEVEL:-1}" -le 0 ] && cmd+=(--quiet)
302-
[ "${LOG_LEVEL:-1}" -ge 2 ] && cmd+=(--verbose)
303-
[ "${LOG_LEVEL:-1}" -ge 3 ] && cmd+=(--verbose)
301+
cmd+=($(get_verbosity_flags))
304302
if [ -n "${SFTP_CONNECTIONS:-}" ]; then
305303
cmd+=(-o "sftp.connections=${SFTP_CONNECTIONS}")
306304
fi
307-
cmd+=(backup)
308-
[ -n "${LIMIT_THREADS:-}" ] && cmd+=(--limit-threads "${LIMIT_THREADS}")
309305
[ -n "${LIMIT_UPLOAD:-}" ] && cmd+=(--limit-upload "${LIMIT_UPLOAD}")
306+
cmd+=(backup)
307+
[ -n "${READ_CONCURRENCY:-}" ] && cmd+=(--read-concurrency "${READ_CONCURRENCY}")
310308
[ -n "${BACKUP_TAG:-}" ] && cmd+=(--tag "$BACKUP_TAG")
311309
[ -n "${COMPRESSION:-}" ] && cmd+=(--compression "$COMPRESSION")
312310
[ -n "${PACK_SIZE:-}" ] && cmd+=(--pack-size "$PACK_SIZE")
@@ -1021,6 +1019,19 @@ run_uninstall_scheduler() {
10211019
fi
10221020
}
10231021

1022+
get_verbosity_flags() {
1023+
local effective_log_level="${LOG_LEVEL:-1}"
1024+
if [[ "${VERBOSE_MODE}" == "true" ]]; then
1025+
effective_log_level=2 # Force verbose level 2 when --verbose is used
1026+
fi
1027+
local flags=()
1028+
[ "$effective_log_level" -le 0 ] && flags+=(--quiet)
1029+
[ "$effective_log_level" -ge 2 ] && flags+=(--verbose)
1030+
[ "$effective_log_level" -ge 3 ] && flags+=(--verbose)
1031+
1032+
echo "${flags[@]}"
1033+
}
1034+
10241035
# =================================================================
10251036
# MAIN OPERATIONS
10261037
# =================================================================
@@ -1120,7 +1131,9 @@ run_backup() {
11201131
run_forget() {
11211132
echo -e "${C_BOLD}--- Cleaning Old Snapshots ---${C_RESET}"
11221133
log_message "Running retention policy"
1123-
local forget_cmd=(restic forget)
1134+
local forget_cmd=(restic)
1135+
forget_cmd+=($(get_verbosity_flags))
1136+
forget_cmd+=(forget)
11241137
[ -n "${KEEP_LAST:-}" ] && forget_cmd+=(--keep-last "$KEEP_LAST")
11251138
[ -n "${KEEP_DAILY:-}" ] && forget_cmd+=(--keep-daily "$KEEP_DAILY")
11261139
[ -n "${KEEP_WEEKLY:-}" ] && forget_cmd+=(--keep-weekly "$KEEP_WEEKLY")

restic-backup.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
76b6f327716705777a04e4fe784fcdc5b9f125dcc302753aa08d871c28254435 restic-backup.sh
1+
c81e8a05b96574f64acccf3860163e5b15e27d1c264c8ef0d6f98caf80f81af7 restic-backup.sh

0 commit comments

Comments
 (0)