#!/bin/sh t=0 first_check () { timestamp=`/usr/bin/find /opt/backup/mysql_hourly/* -mmin -65 | wc -l` if [ $timestamp -ne "0" ] then echo "Actual file exists" 1> /dev/null size=`/usr/bin/find /opt/backup/mysql_hourly/* -size -250k | wc -l` if [ $size -eq "0" ] then echo "Backup is working" 1> /dev/null t=1 else echo "Backup has failed - filesize < 250k" 1> /dev/null fi else echo "Backup has failed - file timestamp > 65 minutes" 1> /dev/null fi } second_check () { timestamp=`/usr/bin/find /opt/backup/mysql_hourly/* -mmin -65 | wc -l` if [ $timestamp -ne "0" ] then echo "Actual file exists" 1> /dev/null size=`/usr/bin/find /opt/backup/mysql_hourly/* -size -250k | wc -l` if [ $size -eq "0" ] then echo "Backup is working" 1> /dev/null else echo "`date` Backup has failed - filesize < 250k" >> /var/log/test_backup_errorlog fi else echo "`date` Backup has failed - file timestamp > 65 minutes" >> /var/log/test_backup_errorlog fi } inuse=1 while [ $inuse -ne "0" ] do inuse=`lsof +D /opt/backup/mysql_hourly/ | wc -l` if [ $inuse -eq "0" ] then first_check if [ $t -eq "0" ] then second_check else echo "Backup is working" 1> /dev/null fi fi sleep 20 done