undrop-for-innodb是针对Innodb存储引擎的一套数据恢复工具,下面的几种情况都支持。这个工具在github上。如果想寻求商业支持,还可以放问https://twindb.com/mysql-data-recovery/
A table or database was dropped.
InnoDB table space corruption.
Hard disk failure.
File system corruption.
Records were deleted from a table.
A table was truncated.
InnoDB files were accidentally deleted.
A table was dropped and created empty one.
三个重要的工具
c_parser ,stream_parser ,sys_parser
从Makefile文件中,我们可以看到,sys_parser.c这个需要MySQL的安装路径
sys_parser: sys_parser.c
@ which mysql_config || (echo "sys_parser needs mysql development package( either -devel or -dev)"; exit -1)
$(CC) -o $@ $< `mysql_config --cflags` `mysql_config --libs`
如何安装和编译
[root@ohs1 ~]# git clone https://github.com/twindb/undrop-for-innodb.git
[root@ohs1 ~]# cd undrop-for-innodb
[root@ohs1 undrop-for-innodb]# make
注意:编译需要这些`make`, `gcc`, `flex` and `bison`
下面是恢复从几个场景,最下面哪个链接还中文的介绍。如果感兴趣,可以参考。
- Recover Table Structure From InnoDB Dictionary – how to generate CREATE TABLE statement if you have ibdata1 file.
- Take image from corrupted hard drive – what you should do if a hard disk is dying.
- Recover Corrupt MySQL Database – how to recover database from corrupt InnoDB tablespace. The same approach can be taken to recover from corrupt file system.
- Recover after DROP TABLE. Case 2 – how to recover InnoDB table if it was dropped and innodb_file_per_table was ON (a separate .ibd file per table).
- Recover after DROP TABLE. Case 1 – how to recover InnoDB table if it was dropped and innodb_file_per_table was OFF (all tables are in ibadat1 file).
- Recover InnoDB dictionary – how to recover and read InnoDB dictionary tables.
- UnDROP tool for InnoDB – describes tools of the toolkit, their usage, command line options.
- InnoDB dictionary – describes InnoDB dictionary, its tables and format.
- Overview of Undrop-for-InnoDB - Recovery after DROP table,innodb_file_per_tableON and OFF, corrupted database recovery (在普通话)
Reference
https://dev.mysql.com/doc/refman/8.0/en/innodb-troubleshooting-datadict.html
https://github.com/twindb/undrop-for-innodb
https://yq.aliyun.com/articles/281230