Check db2 backup

Here a usefull script to check backup on all dbs in a db2 instance.
It can be used with monitoring products as zabbix or nagios.

NOW=`date -d '1 day ago' '+%Y%m%d'`
UNIQUE=`date +%Y%m`
su - $INS -c "db2 list database directory" | grep alias | awk '{ print $4 }' > $DBS
while read LN; do
  RESULT=$(su - $INS -c " db2 list history backup since $NOW for $LN" | grep 'B  D' -m 1 | awk '{print $3}')
  if [ -z "${RESULT}" ]; then
   RESULT=" : !!!!!!!!!!!!!! !!!!!!!!!!!!!! ERROR"
  echo $LN $RESULT >> $OUTZ
done < $DBS
cat $OUTZ
rm $DBS
rm $OUTZ

Leave a Reply

Your email address will not be published. Required fields are marked *

Antispam Question * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.