简单实用的mysql数据库备份 网页文件备份
短信预约 -IT技能 免费直播动态提醒
安装percona-xtrabackup
http://990487026.blog.51cto.com/10133282/1759237
root@uat:/backup# cat xtrabackup.sh
#!/bin/bash
backdir=/backup/mysql
web_page_backdir=/backup/
user=r**t
pass=a**********t
logfile=innobackupex.log
#备份网页文件
mytime=`date +"%F_%H-%M-%S"`
cd /var/www/
tar -zcf ${mytime}_html.tar.gz html/
mv ${mytime}_html.tar.gz $web_page_backdir
week=`date +%u`
mkdir $backdir >> /dev/null 2>&1
if [ ! -f /globalback ]
then
cat /dev/null > $logfile
innobackupex --user=$user --password=$pass $backdir
stat=`echo $?`
ls $backdir | tail -n 1 > /globalback
basedir=`cat /globalback`
last=`ls $backdir | tail -n 1`
date "+%F %H:%M" >> $logfile
if [ $stat -ne 0 ]
then
echo "备份失败!" >> $logfile
exit
fi
echo " 检测到之前没有做过全局备份,完全备份一次!" >> $logfile
basedir=`cat /globalback`
echo "基 本库是 $backdir/$basedir " >> $logfile
exit
fi
if [ $week -eq 7 ]
then
innobackupex --user=$user --password=$pass $backdir
stat=`echo $?`
incre=`ls $backdir | tail -n 1`
if [ $stat -ne 0 ]
then
date "+%F %H:%M" >> $logfile
echo "备份失败!" >> $logfile
exit
fi
ls $backdir | tail -n 1 > /globalback
basedir=`cat /globalback`
echo "↓↓↓↓↓↓↓↓↓↓↓ 每周全局备份分割线 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓" >> $logfile
date "+%F %H:%M" >> $logfile
echo "全局备份" >> $logfile
echo "数据备份的位置 $backdir/$basedir " >> $logfile
basedir=`cat /globalback`
echo "基 本库是 $backdir/$basedir " >> $logfile
else
basedir=`cat /globalback`
last=`ls $backdir | tail -n 1`
innobackupex --user=$user --password=$pass --incremental $backdir --incremental-basedir=$backdir/$last
stat=`echo $?`
incre=`ls $backdir | tail -n 1`
echo "" >> $logfile
date "+%F %H:%M" >> $logfile
if [ $stat -ne 0 ]
then
echo "备份失败!" >> $logfile
exit
fi
echo "增量备份 " >> $logfile
echo "基 本库是 $backdir/$basedir " >> $logfile
echo "本次备份是 $backdir/$incre " >> $logfile
echo "MySQL二进制日志文件路径" >> $logfile
grep "^log.bin" /etc/mysql/my.cnf >> $logfile
fi
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341