check_backuppc/check_backuppc_nb_bkp_v3
2024-10-07 12:59:39 +02:00

52 lines
1.2 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
VERSION=dev
if [[ "$1" == "-v" ]] || [[ "$1" == "--version" ]] || [[ "$1" == "version" ]]; then
echo "$( basename "$0" ) - $VERSION"
exit 0
fi
[[ ! -d /var/lib/backuppc/pc ]] && echo "BackupPC directory not found (/var/lib/backuppc/pc)." && exit 1
if ! cd "/var/lib/backuppc/pc"; then
echo "Failed to enter in BackupPC directory (/var/lib/backuppc/pc)."
exit 1
fi
OUT="<table align=center>
<thead>
<tr>
<th rowspan=2 align=left>Host</th>
<th colspan=2>Nb backups</th>
<tr>
<th>Before V4</th>
<th>After V4</th>
</tr>
</thead>
<tbody>"
t_v3=0
t_v4=0
for h in *; do
if [[ ! -d "$h" ]] || [[ ! -e "$h/backups" ]]; then
continue
fi
vers=$( cut -f24 < "$h/backups" )
v3=$( grep -Evc '^4' <<< "$vers" )
((t_v3=t_v3+v3))
[[ "$v3" -ne 0 ]] && v3="<strong>$v3</strong>"
v4=$( grep -Ec '^4' <<< "$vers" )
((t_v4=t_v4+v4))
OUT="$OUT<tr><td align=left>$h</td><td>$v3</td><td>$v4</td></tr>"
done
[[ $t_v3 -gt 0 ]] && t_v3="<strong>$t_v3</strong>"
OUT="$OUT
</tbody>
<tfooter>
<tr>
<th align=right>Total :</th>
<th>$t_v3</th>
<th>$t_v4</th>
</tr>
</tfooter>
</table>"
lynx -stdin <<< "$OUT"
# vim:set sw=4 ts=4 sts=4 ft=bash expandtab: