# innobackupex --user=root --password=redhat --defaults-file=/usr/local/webserver/mysql5.6/my.cnf --apply-log /data/backup/base/ --incremental-dir=/data/backup/incremental_two/
innobackupex: Copying '/data/backup/incremental_two/performance_schema/setup_instruments.frm' to '/data/backup/base/performance_schema/setup_instruments.frm'
innobackupex: Copying '/data/backup/incremental_two/db01/db.opt' to '/data/backup/base/db01/db.opt'
innobackupex: Copying '/data/backup/incremental_two/db01/t2.frm' to '/data/backup/base/db01/t2.frm'
160201 16:18:27 innobackupex: completed OK!
数据恢复
# innobackupex --user=root --password=redhat --defaults-file=/usr/local/webserver/mysql5.6/my.cnf --copy-back /data/backup/base/
...........................................
innobackupex: Starting to copy InnoDB system tablespace
innobackupex: in '/data/backup/base'
innobackupex: back to original InnoDB data directory '/usr/local/webserver/mysql5.6/data'
innobackupex: Copying '/data/backup/base/ibdata1' to '/usr/local/webserver/mysql5.6/data/ibdata1'
innobackupex: Starting to copy InnoDB undo tablespaces
innobackupex: in '/data/backup/base'
innobackupex: back to '/usr/local/webserver/mysql5.6/data'
innobackupex: Starting to copy InnoDB log files
innobackupex: in '/data/backup/base'
innobackupex: back to original InnoDB log directory '/usr/local/webserver/mysql5.6/data'
innobackupex: Finished copying back files.
160201 16:23:08 innobackupex: completed OK!
查看目录
# ll /usr/local/webserver/mysql5.6/data/ #这个目录下的数据已经恢复回来
total 79916
drwxr-x---. 2 root root 4096 Feb 1 16:18 db01
-rw-r-----. 1 root root 79691776 Feb 1 16:18 ibdata1
drwx------. 2 root root 4096 Feb 1 15:26 mysql
drwxr-xr-x. 2 root root 4096 Feb 1 15:26 performance_schema
drwxr-x---. 2 root root 4096 Feb 1 16:13 sharelinux
drwxr-xr-x. 2 root root 4096 Feb 1 15:26 test
-rw-r--r--. 1 root root 22 Feb 1 16:18 xtrabackup_binlog_info
-rw-r-----. 1 root root 91 Feb 1 16:18 xtrabackup_checkpoints
-rw-r--r--. 1 root root 722 Feb 1 16:18 xtrabackup_info
-rw-r-----. 1 root root 2097152 Feb 1 16:09 xtrabackup_logfile
drwx------. 2 root root 12288 Feb 1 15:26 zabbix
#chown mysql:mysql /usr/local/webserver/mysql5.6/data/ -R #将目录更改为mysql用户
# pkill mysql #杀死原来的mysql进程,然后重启数据库
# service mysqld start
Starting MySQL.. [ OK ]
数据已经恢复回来了
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db01 |
| mysql |
| performance_schema |
| sharelinux |
| test |
| zabbix |
+--------------------+
7 rows in set (0.14 sec)
mysql> select * from sharelinux.t1; #第一次增量备份的数据
+------+----------+
| id | name |
+------+----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | wangwu |
+------+----------+
3 rows in set (0.03 sec)
mysql> select * from db01.t2; #第二次增量备份的数据
+------+----------+
| id | name |
+------+----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | wangwu |
+------+----------+
3 rows in set (0.08 sec)