Skip to content

Instantly share code, notes, and snippets.

@northox
Created July 16, 2017 15:53
Show Gist options
  • Save northox/59ec4c488e1bc116584dffaf958feaa7 to your computer and use it in GitHub Desktop.
Save northox/59ec4c488e1bc116584dffaf958feaa7 to your computer and use it in GitHub Desktop.
Compares the number of bacula's clients within the director config with todays successful backups. It assumes client's name are right after the 'Client {' opening brackets.
#!/bin/ksh
DIRPATH='/etc/bacula/bacula-dir.conf'
NOERROR='Backup missing for: '
ERROR=$NOERROR
TODAY=`date "+%v" | sed 's/-20/-/'`
OKSTATUS=`echo 'status storage=FileStorage' | bconsole | grep ${TODAY} | grep OK`
CLIENTS=`grep '^Client {' -A1 $DIRPATH | grep Name | sed -E 's/ +Name = ([a-zA-Z]+)-fd/\1/'`
for c in $CLIENTS; do
echo -n "$OKSTATUS" | grep -q $c
if [ $? -ne 0 ]; then
ERROR="${ERROR}$c "
fi
done
if [ "$ERROR" != "$NOERROR" ]; then
echo $ERROR
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment