|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!该剧本完成了对近程备份到ftp办事器的数据完全性及是不是ftp到该办事器举行了反省,假如没有实时备份到该ftp办事器则剧本会触发短信告警功效模块完成短信的告警,最初因为ftp办事器的空间无限,笔者在收罗相干职员已后制订了90天之前的数据举行删除的战略并在剧本中也完成了该功效。现将该剧本贴出以供人人进修参考。
#!/usr/bin/ksh
#---------------------------------------------------------
#scriptname:
#monthedatabackup
#version:
#1.2
#description:
#-ifyouhave"/opt/mon/backup/my.lock",themonitorisunavailability;
#-iffindserviceerror,sendmessagetoadmin.
#method:
#author:
#createbyfengzhanhai
#notes:
#-thereturnvariantiscorrectequal0,errorequal1.
#---------------------------------------------------------
#scriptconf---------------------------------------------
Mon_Path="/backup/autobk/mon"
Mon_log="$Mon_Path/backup.log"
SMS_Server="yoursmsiporfetionrobot"
SMS_Send="$Mon_Path/sendsms"
Admin_Mobile="$Mon_Path/youmobilelist"
SMS_From=`hostname`
SMS_Header="Your-Mysql--DataBackup-"
Service_IP="yourftpserver"
#checkthelockfile------------------------------------
getLock()
{
if[-f"$Mon_Path/$Service_Name.lock"];then
return1
else
return0
fi
}
#writerthemessagetolog--------------------------
logwriter()
{
if[!-d`dirname$Mon_log`];then
mkdir-p`dirname$Mon_log`
fi
echo`date"+%Y-%m-%d%H:%M:%S"`:$1>>$Mon_log
}
#senderrorsmstoadmin---------------------
sendSmsToAdmin()
{
CurTime=`date"+%Y-%m-%d%H:%M:%S"`
if[$#-eq1];then
if[!-z"$1"];then
tmpTime=`date"+%Y%m%d%H%M%S"`
formobilein`cat$Admin_Mobile`
do
$SMS_Send-h$SMS_Server$mobile"$SMS_Header$1notupdate-$tmpTime-$SMS_From"
done
fi
else
logwriter"callsendSmsToAdminarguserror"
fi
}
#checkthelockfile------------------------------------
getlastfile()
{
find$1-name"$2`date"+%Y%m%d"`*.$3"|grep$2
if[$?=0];then
return0
else
return1
fi
}
#main---------------
#反省锁文件
logwriter"backupcheckbegin"
getLock
if[$?=0];then
#反省当日文件是不是存在
getlastfile/eip_backup/autobk/yourdb/mysqlyourdatatgz
if[$?!=0];then
logwriter"yourdbnotupdate!"
#发送告警短信
sendSmsToAdmin"yourapp"
fi
logwriter"yourappcheckover."
#清算90天前的备份数据
find/eip_backup/autobk/yourdb/mysql-name"yourdb*.tgz"-ctime+90-print-execrm{};
logwriter"deleteyourdbfileover."
logwriter"backupcheckover"
欢迎大家来到仓酷云论坛! |
|