Shell-Check MySQL Backup Status

来源:互联网 发布:mac录屏软件 编辑:程序博客网 时间:2024/04/30 23:57
# ######################################################################### Purpose:Check MySQL Backup  status# Authors:Kin Zhang# Version:v1.0# Date:2013-02-18# ########################################################################bak_dir=/mysqlbak/log=`find ${bak_dir} -name xtrabk.log`chklog=/tmp/kin.logtoday=`date +%y%m%d`bak_time=`date +%H`function fetch_result(){> ${chklog}for i in ${log}dohost=`echo ${i}|cut -d '/' -f3`record=`grep "innobackupex-1.5.1\: completed OK\!" ${i}|tail -n 1|awk '{print $1,$4}'`echo "${host} ${record}" >> ${chklog}done}function check_logic(){bakdate=`cat ${chklog} |awk '{print $2}'`for x in ${bakdate}doif [ ${x} -lt ${today} ];thenstr=`grep ${x} ${chklog}`echo "Critical:please check your ${str}" && exit 2fidoneecho "OK:mysql backup is OK!" && exit 0}function check_bakfile(){if [ ${bak_time} -ge 6 ]; thencheck_logic;fi}fetch_resultcheck_bakfile

原创粉丝点击