Mysql Undrop for Innodb Database recovery script

There is a link on the desktop to TwinDB’s website, this help a lot to understand the concept and how to recover a corrupted table.

But when you want to recover a full database with let’s say 100+ table it could be a real pain because there is a lot of command to recover table structure and data.

So i made a little shell script (your database must be innodb_file_per_table=1)

So let’s start, first, download the script :

wget http://mysql.on.windows.free.fr/wp-download/RecovDB.sh

then grant the right to execute the scripts

chmod +x RecovDB.sh

then, launch the script !

./RecovDB dataDirPath dbname

  1. replace dataDirPath by the MySQL data directory path
  2. replace dbname by the name of the database you want to recover

Then you will have a subfolder “dump” created, you will find some files :

  • Load Data.SQL > script to reinject data
  • [tableX].sql > Table create statement (1 file per table)
  • [tableX].data > Table data (1 file per table)

Note that you can use this script anywhere , you only need undrop for innodb and a mysql service listening on port 3306.

Hope this helps 🙂