标签:
1、创建备份相关用户
create user ‘backuper‘@‘127.0.0.1‘ identified by ‘123456‘; grant reload,lock tables,replication client,process,super on *.* to ‘backuper‘@‘127.0.0.1‘; grant create,insert,select on percona_schema.xtrabackup_history to ‘backuper‘@‘127.0.0.1‘; create user ‘backuper‘@‘localhost‘ identified by ‘123456‘; grant reload,lock tables,replication client,process,super on *.* to ‘backuper‘@‘localhost‘; grant create,insert,select on percona_schema.xtrabackup_history to ‘backuper‘@‘localhost‘;
2、创建全备
innobackupex --user=backuper --password=123456 --host=127.0.0.1 --port=3306 /tmp/backup/
3、创建增备
innobackupex --user=backuper --password=123456 --host=127.0.0.1 --port=3306 --incremental --incremental-basedir=/tmp/backup/2016-09-07_04-14-17 /tmp/backup_incremental
4、在全备上前滚日志
innobackupex --apply-log --redo-only /tmp/backup/2016-09-07_04-14-17
5、在增备上前滚&回滚日志
innobackupex --apply-log --incremental-dir=/tmp/backup_incremental/2016-09-07_04-22-36 /tmp/backup/2016-09-07_04-14-17
6、把处于一致的备份复制到datadir目录下
innobackupex --defaults-file=/etc/my.cnf --copy-back /tmp/backup/2016-09-07_04-14-17
7、调整数据的属主,属组 & 启动mysql服务
chown -R mysql:mysql /usr/local/mysql/data service mysqld start
8、以single-file的方式来备份数据库
innobackupex --user=backuper --password=123456 --host=127.0.0.1 --port=3306 --stream=xbstream /tmp >/tmp/backup/mysql_3306_full.xbstream
9、把单文件解包成文件夹
xbstream -x < /tmp/backup/mysql_3306_full.xbstream -C /tmp/datadir
10、前滚&回滚日志
innobackupex --apply-log --use-memory=2G /tmp/datadir
11、把处于一致的备份复制到datadir目录下
innobackupex --defaults-file=/etc/my.cnf --copy-back /tmp/datadir
标签:
原文地址:http://www.cnblogs.com/JiangLe/p/5847081.html