From eaa4914b727c64c51102d5dfbcb2d9df56c284b3 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 27 May 2025 19:24:52 +0200 Subject: [PATCH] add history log rotate --- backup | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backup b/backup index 3ffc50c..56d2ac8 100755 --- a/backup +++ b/backup @@ -186,6 +186,7 @@ make_history() local time="$(date +%T)" local history_path="history" local typ="none" + local history_size=0 [ -f "$backup_path/day" ] && typ="day" [ -f "$backup_path/week" ] && typ="week" @@ -193,6 +194,14 @@ make_history() mkdir --parents "$history_path" + [ -f "$history_path/$backup_history_file" ] \ + && history_size=$(cat $history_path/$backup_history_file \ + | wc -c) + echo "ℹ️ INFO: $history_path/$backup_history_file size $history_size bytes" + [ $history_size -ge 1024 ] \ + && savelog -c 7 -l $history_path/$backup_history_file \ + && echo "ℹ️ INFO: $history_path/$backup_history_file rotate" + echo "ℹ️ INFO: add history $date $time $typ $backup_dir" echo "$date" > $backup_path/$typ echo "$date" > $history_path/$typ @@ -260,6 +269,15 @@ main() command -v ssh > /dev/null \ || errlog "command ssh not found" \ || return $? + command -v savelog > /dev/null \ + || errlog "command savelog not found" \ + || return $? + command -v du > /dev/null \ + || errlog "command du not found" \ + || return $? + command -v wc > /dev/null \ + || errlog "command wc not found" \ + || return $? [ -f "config.yaml" ] \ || errlog "file config.yaml not found" \ || return $? -- 2.47.3