]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add history log rotate
authorBastian Dehn <hhaalo@arcor.de>
Tue, 27 May 2025 17:24:52 +0000 (19:24 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 27 May 2025 17:24:52 +0000 (19:24 +0200)
backup

diff --git a/backup b/backup
index 3ffc50c072cea21a3f4ad0ffd7ae231b2316a305..56d2ac85e8ae86adad945d69aae1eff2c3c5ab84 100755 (executable)
--- 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 $?