diff --git a/check_clientbackup.sh b/check_clientbackup.sh index 73d568840c87f49bed208a605bae4509e220b42e..3b0e1962d87ef8e943899c668a37829783a8b5a1 100755 --- a/check_clientbackup.sh +++ b/check_clientbackup.sh @@ -18,6 +18,7 @@ # 2022-10-20 ah v1.4 show last backup, prune and verify # 2023-09-01 ah v1.5 add counters for new/ changed/ deleted fileobjects (Restic only) # 2023-09-04 ah v1.6 fix perfdata dirs-del= +# 2024-08-28 ah v1.7 update counter new/ changed/ deleted fileobjects without restic snapshot comparison # ============================================================================== . $(dirname $0)/includes/jobhelper.sh @@ -154,16 +155,31 @@ else if cat $logfile | grep restic >/dev/null; then echo ">>> Counters:" - iModFNew=$( cat $logfile | grep -c "^+ /.*[^/]$" ) - iModDNew=$( cat $logfile | grep -c "^+ /.*/$" ) - iModFChange=$( cat $logfile | grep -c "^M /.*[^/]$" ) - iModDChange=$( cat $logfile | grep -c "^M /.*/$" ) - iModFDelete=$( cat $logfile | grep -c "^- /.*[^/]$" ) - iModDDelete=$( cat $logfile | grep -c "^- /.*/$" ) - - printf "__COUNTERS__New: %10s files %10s dirs\n" $iModFNew $iModDNew - printf "__COUNTERS__Changed: %10s files %10s dirs\n" $iModFChange $iModDChange - printf "__COUNTERS__Deleted: %10s files %10s dirs\n" $iModFDelete $iModDDelete + + # This is faster andd doesn't need comparison of snapshots in output + # and works with initial backups too + iModFNew=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$2;} END {print sum;}' ) + iModFChange=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$4;} END {print sum;}' ) + iModFNone=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$6;} END {print sum;}' ) + iModFDelete=$( cat $logfile | grep "^Files:.*removed" | awk '{sum+=$4;} END {print sum;}' ) + + iModDNew=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$2;} END {print sum;}' ) + iModDChange=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$4;} END {print sum;}' ) + iModDNone=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$6;} END {print sum;}' ) + iModDDelete=$( cat $logfile | grep "^Dirs:.*removed" | awk '{sum+=$4;} END {print sum;}' ) + + # old way: + # iModFNew=$( cat $logfile | grep -c "^+ /.*[^/]$" ) + # iModDNew=$( cat $logfile | grep -c "^+ /.*/$" ) + # iModFChange=$( cat $logfile | grep -c "^M /.*[^/]$" ) + # iModDChange=$( cat $logfile | grep -c "^M /.*/$" ) + # iModFDelete=$( cat $logfile | grep -c "^- /.*[^/]$" ) + # iModDDelete=$( cat $logfile | grep -c "^- /.*/$" ) + + printf "__COUNTERS__New: %10s files %10s dirs\n" $iModFNew $iModDNew + printf "__COUNTERS__Changed: %10s files %10s dirs\n" $iModFChange $iModDChange + printf "__COUNTERS__Deleted: %10s files %10s dirs\n" $iModFDelete $iModDDelete + printf "__COUNTERS__Unchanged: %10s files %10s dirs\n" $iModFNone $iModDNone echo "__PERFDATA__ |files-new=$iModFNew;;;0 files-mod=$iModFChange;;;0 files-del=$iModFDelete dirs-new=$iModDNew;;;0 dirs-mod=$iModDChange;;;0 dirs-del=$iModDDelete;;;0" echo fi