#!/bin/bash

BASEPATH="/backup/mysql/localhost/daily/"

[ -f /etc/nagios/check_automysqlbackup.conf ] && . /etc/nagios/check_automysqlbackup.conf

count=$( find ${BASEPATH}. -type f -name '*.bz2' -o -name '*.gz' -o -name '*.sql' -mtime 0 | wc -l )
 
if [ $count -gt 0 ] ; then
	echo "OK: found $count table backup files"
	exit 0
else
	echo "ERROR: Latest MySQL backup is older than 24 hours, please check!"
	exit 2
fi
echo "UNKOWN"
exit 3
