备份文件路径 backdir=/ASSET.innobackupex mysql用来备份用户 user=用户名 mysql用户的密码 pass=密码 输出的信息保存路径 logfile=/var/www/html/index.html
[root@localhost /home]# cat /home/innobackupex.v2.sh #!/bin/bash backdir=/ASSET.innobackupex user=username pass=yourpassword logfile=/var/www/html/files/index.html 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` echo "<br><br>" date >> $logfile if [ $stat -ne 0 ] then echo "备份失败!" >> $logfile exit fi echo "<br> 检测到之前没有做过全局备份,完全备份一次!<br>" >> $logfile echo -n "本次全局备份使用的二进制日志文件,截止位置信息:" >> $logfile cat $backdir/$basedir/xtrabackup_binlog_info >> $logfile echo -n "<br> 二进制日志文件路径" >> $logfile grep "^log-bin" /etc/my.cnf >> $logfile echo "<br>本次数据库备份文件份的lsn信息如下:<br>开始位置:" >> $logfile grep from_lsn $backdir/$last/xtrabackup_checkpoints >> $logfile echo "<br>结束位置: " >> $logfile grep to_lsn $backdir/$last/xtrabackup_checkpoints >> $logfile echo "<br> 备份文件的大小、路径" >> $logfile du -sh $backdir/$last/ >> $logfile echo "<br>" >> $logfile exit fi if [ $week -eq 5 ] then innobackupex --user=$user -password=$pass $backdir stat=`echo $?` incre=`ls $backdir | tail -n 1` if [ $stat -ne 0 ] then echo "<br><br>" >> $logfile date >> $logfile echo "<br>备份失败!" >> $logfile exit fi ls $backdir | tail -n 1 > /globalback basedir=`cat /globalback` echo "<br><br>↓↓↓↓↓↓↓↓↓↓↓ 全局备份分割线 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓<br><br>" >> $logfile date >> $logfile echo "<br>全局备份<br>" >> $logfile echo "数据备份的位置 $backdir/$basedir <br>" >> $logfile echo -n "本次全局备份使用的二进制日志文件,截止位置信息:" >> $logfile cat $backdir/$basedir/xtrabackup_binlog_info >> $logfile echo -n "<br> 二进制日志文件路径" >> $logfile grep "^log-bin" /etc/my.cnf >> $logfile echo "<br>本次数据库备份文件份的lsn信息如下:<br>开始位置:" >> $logfile grep from_lsn $backdir/$basedir/xtrabackup_checkpoints >> $logfile echo "<br>结束位置: " >> $logfile grep to_lsn $backdir/$basedir/xtrabackup_checkpoints >> $logfile echo "<br> 备份文件的大小、路径" >> $logfile du -sh $backdir/$basedir >> $logfile echo "<br>" >> $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 "<br><br>" >> $logfile date >> $logfile if [ $stat -ne 0 ] then echo "备份失败!" >> $logfile exit fi echo "<br>增量备份 <br>" >> $logfile echo "基 本库是 $backdir/$basedir <br>" >> $logfile echo "上次备份是 $backdir/$last <br>" >> $logfile echo "本次备份是 $backdir/$incre <br>" >> $logfile echo -n "上次全局备份使用的二进制日志文件,截止位置信息:" >> $logfile cat $backdir/$basedir/xtrabackup_binlog_info >> $logfile echo -n "<br> 本次增量备份使用的二进制日志文件,截止位置信息:" >> $logfile cat $backdir/$incre/xtrabackup_binlog_info >> $logfile echo -n "<br>二进制日志文件路径" >> $logfile grep "^log-bin" /etc/my.cnf >> $logfile echo "<br>本次增量数据库备份文件份的lsn信息如下:<br>开始位置:" >> $logfile grep from_lsn $backdir/$incre/xtrabackup_checkpoints >> $logfile echo "<br>结束位置: " >> $logfile grep to_lsn $backdir/$incre/xtrabackup_checkpoints >> $logfile echo "<br> 增量备份文件的大小、路径" >> $logfile du -sh $backdir/$incre >> $logfile echo "<br>" >> $logfile fi
.
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。