第3章 backup服务器实现校验,删除,报警
首先我们测试下如果实现服务器报警
[root@backup ~]# tail -1 /etc/mail.rc
set from=njlc_jsbcmq@linuxidc.com smtp=smtp.163.com smtp-auth-user=njlc_jsbcmq smtp-auth-password=hgg7454196ls smtp-auth=login
[root@backup ~]# echo "31qqi zuzi bang"|mail -s "nihao" linuxidc@linuxidc.com
就可以收到邮件了
[root@backup scripts]# cat checkbak.sh
#!/bin/bash
export
if [ $(date +%w) -eq 2 ];then
date="$(date +%F -d "-1day")_week1"
else
date="$(date +%F -d "-1day")"
fi
find /backup/ -name "flag_${date}*"|xargs md5sum -c &>>/tmp/mail_$(date +%F).log
find /backup/ -type f -name "*.tar.gz" -a ! -name "*week1*" -mtime +1|xargs rm -f
mail -s "backup ~date~" linuxidc@linuxidc.com </tmp/mail_$(date +%F).log
\cp /tmp/mail_$(date +%F).log /tmp/mail_$(date +%F).log.ori
>/tmp/mail_$(date +%F).log
做定时任务,每天上午6点发送邮箱
[root@backup scripts]# crontab -l
* * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
* * * * * /bin/bash /server/scripts/checkbak.sh >/dev/null 2>&1
项目完成
inotify-tools+rsync实时同步文件安装和配置
CentOS 6.5下Rsync远程同步