相关说明:http://blog.csdn.net/mr_mablevi/article/details/5860571
继去年测试以后一直没有把xtrabackup备份用起来,现在刚好针对目前的环境从新整理了一下:
用了Xtrabackup-1.6的二进制版本,经测试均没有问题,测试方法见:http://blog.csdn.net/mr_mablevi/article/details/5860571
不了解可以看help.
针对上面的方法做了一个备份脚本:压缩前一天的,当天的不压缩,(因为要是有问题,当天的备份马上可以恢复,不需要解压)
#!/bin/sh
backup_dir="/usr/local/innobackup"
innobackupex --user=root --password=rootman --slave-info $backup_dir > $backup_dir/innobackup.log 2>&1
backup_name=`ls -ll $backup_dir | awk '{if($1~/d/) print $NF}' | grep 20 | sort -r | head -1`
innobackupex --user=root --password=rootman --apply-log $backup_dir/$backup_name > $backup_dir/innobackup_apply.log 2>&1
backup_name_yd=`ls -ll $backup_dir | awk '{if($1~/d/) print $NF}' | grep 20 | sort | head -1`
backup_info=`echo "$backup_name_yd.tar.bz2 $backup_name_yd/"`
echo $backup_info > $backup_dir/backup_info.log
cd $backup_dir
file_num=`ls -ll $backup_dir | awk '{if($1~/d/) print $0}'| wc -l`
if [ "$file_num" -gt 1 ]
then
tar -cjf $backup_name_yd.tar.bz2 $backup_dir/$backup_name_yd/
rm -rf $backup_name_yd
else
exit
fi
压缩包用tar -xjf 来解压文件.