mysql xtrabackup

2019-11-12 16:18:38 浏览数 (1)

1、安装 rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm yum install perl-DBI yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL yum -y install perl-Digest-MD5 wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.10/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm 2、创建备份用户

image.png

3、调整数据库配置

image.png

4、全量备份

代码语言:javascript复制
#!/bin/bash
#Description:xtrabackup complete
#Author:created by michael
#2017-08-07 v0.1
#
USER=root
PASSWD=123456
BACKUP_DIR=/backup/mysql/complete
DATE=$(date  "%F_%T")
[[ -d $BACKUP_DIR ]] || mkdir $DATE_DIR
innobackupex --user=$USER --password=$PASSWD $BACKUP_DIR &> /tmp/mysql/"$DATE".txt
egrep ".* Backup created in directory.*" /tmp/mysql/"$DATE".txt >> $BACKUP_DIR/complete.info
rm -rf /tmp/mysql/"$DATE".txt

chmod 755 /root/script/backup_complete.sh

crontab -e 每周六的凌晨4点整定时执行全量备份

0 4 * * 6 /root/script/backup_complete.sh

定期删除

find /backup/mysql/completel -mtime 7 -exec rm -rf {} ;

5、增量备份 [root@michaelos script]# cat backup_increment.sh

!/bin/bash

Description: mysql backup incremention

Author:michael

2017-08-07 v0.1

USER=root PASSWORD=123456 BACKUP_DIR=/backup/mysql/increment DATE=

T") BASE_DIR=

BACKUP_DIR ]] || mkdir

USER --password=

BACKUP_DIR --incremental-basedir=

DATE".txt egrep ".Backup created in directory." /tmp/mysql/"

BACKUP_DIR/backup.info rm -rf /tmp/mysql/"$DATE".txt

chmod 755 backup_increment.sh

crontab -e 每2,4,7晚上2点

0 2 * * 2,4,7 /root/script/backup_increment.sh

6、恢复 innobackupex --apply-log --redo-only /backups/2018-07-30_11-01-37/ innobackupex --apply-log --redo-only /backups/2018-07-30_11-01-37/ --incremental-dir=/backups/2018-07-30_13-51-47/ innobackupex --copy-back /backups/2018-07-30_11-01-37/

0 人点赞