您好,登录后才能下订单哦!
这篇文章主要介绍MySQL中Innobackupex怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
该脚本为Innobackupex全备脚本
Xtrabackup版本:2.4.3
#/bin/bash
#set variables
conf=/XXX/my.cnf #my.cnf的路径
user=
password=
socket=
backupdir=
name=fullback_`date +"%Y%m%d-%H:%M:%S"`
innobackupexlog=${backupdir}/log/innobackupexlog_`date +"%Y%m%d-%H:%M:%S"`
expire=7 #备份的数据保留的时间
#begin full backup
innobackupex --defaults-file=${conf} \
--user=${user} \
--password=${password} \
--socket=${socket} \
--slave-info \
--no-timestamp ${backupdir}/${name}&>>${innobackupexlog}
backupflag1=`tail -n 10 ${innobackupexlog} | grep "completed OK" | grep -v prints | wc -l`
if [ ${backupflag1} -eq 0 ]
then
echo "==============================================================="
echo "`date +"%Y-%m-%d %H:%M:%S"` backup failed!">> ${innobackupexlog}
echo "==============================================================="
exit 1
elif [ ${backupflag1} -eq 1 ]
then
echo "============================================================" >> ${innobackupexlog}
echo "backup success" >>${innobackupexlog}
echo "============================================================" >> ${innobackupexlog}
#begin recover redolog
echo "============================================================" >> ${innobackupexlog}
echo "`date +"%Y%m%d-%H:%M:%S"` Begin to Recover ..." >> ${innobackupexlog}
echo "============================================================" >> ${innobackupexlog}
innobackupex --defaults-file=${conf} --apply-log ${backupdir}/${name} &>>${innobackupexlog}
backupflag2=`tail -n 10 ${innobackupexlog} | grep "completed OK" | grep -v prints | wc -l`
if [ ${backupflag2} -gt 0 ]
then
echo "===============================================================" >>${innobackupexlog}
echo "`date +"%Y%m%d-%H:%M:%S"` Recover is success!" >>${innobackupexlog}
echo "===============================================================" >>${innobackupexlog}
else
echo "===============================================================" >>${innobackupexlog}
echo "Recover is failed!" >>${innobackupexlog}
echo "===============================================================" >>${innobackupexlog}
exit 1
fi
fi
#clean expired backup
find ${backupdir} -type d -name "fullback*" -mtime +${expire} | xargs /bin/rm -rf
find ${backupdir}/log -type f -name "innobackupexlog*" -mtime +${expire} | xargs /bin/rm -rf
以上是“MySQL中Innobackupex怎么用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。