然后执行恢复
- # 全量恢复
- [mysql@mysql-test ~]$ mysql -S /tmp/mysql.sock < backup.sql
- # 应用增量日志
- [mysql@mysql-test ~]$ mysql -S /tmp/mysql.sock < backup_inc.sql
- 检查数据
- chengqm-3306>>select count(*) from mytest.mytest;
- +----------+
- | count(*) |
- +----------+
- | 161 |
- +----------+
- 1 row in set (0.00 sec)
- chengqm-3306>>select * from mytest.mytest order by id desc limit 5;
- +-----+---------------------+
- | id | ctime |
- +-----+---------------------+
- | 161 | 2019-08-09 11:01:53 |
- | 160 | 2019-08-09 11:01:52 |
- | 159 | 2019-08-09 11:01:51 |
- | 158 | 2019-08-09 11:01:50 |
- | 157 | 2019-08-09 11:01:49 |
- +-----+---------------------+
- 5 rows in set (0.00 sec)
已经恢复到 2019-08-09 11:01:54 这个时间点
3 恢复一个表
3.1 从mysqldump备份恢复一个表
假设要恢复的表是 mytest.mytest
- # 提取某个库的所有数据
- sed -n '/^-- Current Database: `mytest`/,/^-- Current Database:/p' backup.sql > backup_mytest.sql
- # 从库备份文件中提取建表语句
- sed -e'/./{H;$!d;}' -e 'x;/CREATE TABLE `mytest`/!d;q' backup_mytest.sql > mytest_table_create.sql
- # 从库备份文件中提取插入数据语句
- grep -i 'INSERT INTO `mytest`' backup_mytest.sql > mytest_table_insert.sql
- # 恢复表结构到 mytest 库
- mysql -u<user> -p mytest < mytest_table_create.sql
- # 恢复表数据到 mytest.mytest 表
- mysql -u<user> -p mytest < mytest_table_insert.sql
3.2 从xtrabackup备份恢复一个表
假设 ./backup_xtra_full 目录为解压后应用过日志的备份文件
3.2.1 MyISAM 表
假设从备份文件中恢复表 mytest.t_myisam,从备份文件中找到 t_myisam.frm t_myisam.MYD t_myisam.MYI 这 3 个文件,复制到对应的数据目录中,并授权
进入 MySQL,检查表情况
- chengqm-3306>>show tables;
- +------------------+
- | Tables_in_mytest |
- +------------------+
- | mytest |
- | t_myisam |
- +------------------+
- 2 rows in set (0.00 sec)
- chengqm-3306>>check table t_myisam;
- +-----------------+-------+----------+----------+
- | Table | Op | Msg_type | Msg_text |
- +-----------------+-------+----------+----------+
- | mytest.t_myisam | check | status | OK |
- +-----------------+-------+----------+----------+
- 1 row in set (0.00 sec)
3.2.2 Innodb 表 (编辑:PHP编程网 - 黄冈站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|