From: Bastian Dehn Date: Tue, 27 May 2025 17:24:52 +0000 (+0200) Subject: add history log rotate X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=eaa4914b727c64c51102d5dfbcb2d9df56c284b3;p=simple-backup.git add history log rotate --- 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 $?