#创建一个测试库zx
[root@rhel7 ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
| wl |
+--------------------+
6 rows in set (0.10 sec)
mysql> create database zx;
Query OK, 1 row affected (0.00 sec)
mysql> exit
Bye
#停止MySQL数据库并创建新的data目录
[root@rhel7 ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@rhel7 ~]# cd $MYSQL_HOME
[root@rhel7 mysql]# ls
bin COPYING data docs include lib man mysql-test README share support-files
[root@rhel7 mysql]# mv data data_bak
[root@rhel7 mysql]# mkdir data
#恢复数据
[root@rhel7 mysql]# innobackupex --copy-back /mysqlbackup/2016-12-13_12-27-13/
161213 13:03:50 innobackupex: Starting the copy-back operation
IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!".
innobackupex version 2.4.5 based on MySQL server 5.7.13 Linux (x86_64) (revision id: e41c0be)
161213 13:03:50 [01] Copying ib_logfile0 to /usr/local/mysql/data/ib_logfile0
161213 13:03:50 [01] ...done
161213 13:03:51 [01] Copying ib_logfile1 to /usr/local/mysql/data/ib_logfile1
161213 13:03:51 [01] ...done
161213 13:03:52 [01] Copying ibdata1 to /usr/local/mysql/data/ibdata1
161213 13:03:54 [01] ...done
161213 13:03:55 [01] Copying ./mysql/plugin.ibd to /usr/local/mysql/data/mysql/plugin.ibd
161213 13:03:55 [01] ...done
161213 13:03:55 [01] Copying ./mysql/servers.ibd to /usr/local/mysql/data/mysql/servers.ibd
161213 13:03:55 [01] ...done
161213 13:03:55 [01] Copying ./mysql/help_topic.ibd to /usr/local/mysql/data/mysql/help_topic.ibd
161213 13:03:55 [01] ...done
161213 13:03:55 [01] Copying ./mysql/help_category.ibd to /usr/local/mysql/data/mysql/help_category.ibd
161213 13:03:55 [01] ...done
.......
161213 13:03:57 [01] Copying ./ibtmp1 to /usr/local/mysql/data/ibtmp1
161213 13:03:57 [01] ...done
161213 13:03:57 completed OK!
#修改data目录下的权限
[root@rhel7 mysql]# chown mysql:mysql -R data
#启动MySQL数据库查看恢复是否成功
[root@rhel7 mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@rhel7 mysql]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
| wl |
+--------------------+
6 rows in set (0.00 sec)
#数据恢复成功,测试数据库zx不见了。
4.增量备份的操作步骤
1)创建备份,增量备份需要有一个全量备份做基础,所以先做一个全量备份再做增量备份