MySQL5.5备份设计之XtraBackup
作者:互联网
基于企业环境的MySQL5.5备份设计,首先安装innobackupex,网上有很多资料,可自行搜索,可自行在https://www.percona.com/downloads/XtraBackup/LATEST/ 寻找包资源
1.安装
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.9/binary/debian/trusty/x86_64/Percona-XtraBackup-2.4.9-ra467167cdd4-trusty-x86_64-bundle.tar
tar -xvf Percona-XtraBackup-2.4.9-ra467167cdd4-trusty-x86_64-bundle.tar
dpkg -i *.deb
apt-get install -f
2.增加脚本
安装完成能看到系统有innobackupex 命令即可
自动每天全备脚本:all_backup.sh
#!/bin/bash
basedir="/data/innobackupex/$(date "+%y%m%d")" ;
sudo innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password='xxxx' $basedir &>> "/data/innobackupex/$(date "+%y%m%d").log"
自动每小时增备脚本:add_backup.sh
#!/bin/bash
basedir="/data/innobackupex/$(date "+%y%m%d")" ;
add_basedir="$basedir/`ls $basedir|tail -n1`";
sudo innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password='xxxxx' --incremental-basedir="$add_basedir" --incremental $basedir &>> "$basedir/$(date "+%y%m%d%H%M").log" ;
####3.为脚本创建相应的定时任务
5 0 * * * sudo /bin/bash /data/innobackupex/all_backup.sh #每天零点5分全备
55 * * * * sudo /bin/bash /data/innobackupex/add_backup.sh #每个小时的55分进行一次增备
后续还需要一些自动清理空间的脚本
4.效果展示
root@xx:/data/innobackupex# pwd
/data/innobackupex
root@xx:/data/innobackupex# ls
181115 181115.log add_backup.sh all_backup.sh
root@xx:/data/innobackupex/181115# pwd
/data/innobackupex/181115
root@xx:/data/innobackupex/181115# ls
1811151113.log 1811151255.log 1811151455.log 2018-11-15_11-08-39 2018-11-15_11-13-07 2018-11-15_12-55-02 2018-11-15_14-55-01
1811151155.log 1811151355.log 2018-11-15_11-05-33 2018-11-15_11-11-14 2018-11-15_11-55-01 2018-11-15_13-55-01
标签:11,log,MySQL5.5,备份,basedir,--,XtraBackup,innobackupex,data 来源: https://blog.csdn.net/wmjCode/article/details/122167044