备份方法见" xtrabackup使用xbstream进行增量流备份"。
从percona server 5.6.19-67.0-log Percona Server (GPL), Release 67.0, Revision 618还原到mysql 5.5.38-log MySQL Community Server (GPL)
完全备份目录:/root/2014-08-06_17-53-47/
增量备份目录:/data/backup/
mysql 5.5.38的数据目录:/data/mysql55/
1、准备完全备份
innobackupex --apply-log --redo-only 2014-08-06_17-53-47
140808 01:31:51 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/root/2014-08-06_17-53-47/backup-my.cnf" --defaults-group="mysqld" --prepare --target-dir=/root/2014-08-06_17-53-47 --apply-log-only --tmpdir=/tmp
...
InnoDB: Shutdown completed; log sequence number 657572237
140808 01:31:51 innobackupex: completed OK!
2、准备增量备份
innobackupex --apply-log 2014-08-06_17-53-47/ --incremental-dir=/data/backup/
140808 01:32:44 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/root/2014-08-06_17-53-47/backup-my.cnf" --defaults-group="mysqld" --prepare --target-dir=/root/2014-08-06_17-53-47 --incremental-dir=/data/backup/ --tmpdir=/tmp
...
InnoDB: Waiting for purge to start
InnoDB: 5.6.17 started; log sequence number 1346283676
[notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1346285250
innobackupex: Starting to copy non-InnoDB files in '/data/backup/'
...
140808 01:32:47 innobackupex: completed OK!
3、应用日志
innobackupex --apply-log 2014-08-06_17-53-47/
140808 01:33:09 innobackupex: Starting ibbackup with command: xtrabackup --defaults-file="/root/2014-08-06_17-53-47/backup-my.cnf" --defaults-group="mysqld" --prepare --target-dir=/root/2014-08-06_17-53-47 --tmpdir=/tmp
...
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1346288696
140808 01:33:21 innobackupex: completed OK!
4、拷贝备份数据到mysql 5.5.38的数据目录/data/mysql55/
先清空数据目录,建议先进行备份:
cd /data/mysql55/
rm -rf *
cp -a /root/2014-08-06_17-53-47/* .
修改权限:
启动mysqld服务:
cd /opt/mysql-5.5.38-linux2.6-x86_64/
./bin/mysqld_safe --defaults-file=./my.cnf --user=mysql &
运行
mysql_upgrade升级权限表:
./bin/mysql_upgrade --defaults-file=my.cnf
5、进行数据校验
如是在主从环境可以使用pt-table-checksum工具
pt-table-checksum --user=root --password=root@123 --host=10.0.37.122 --port=3307 --recursion-method=processlist,hosts --nocheck-replication-filters
--host=10.0.37.122,指定master主机ip地址
--nocheck-replication-filters:不检查复制过滤的库
来自为知笔记(Wiz)