LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-07-2012, 06:36 PM   #1
ckoeber
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Rep: Reputation: 0
Recovering MySQL Database from EXT4 Formatted Hard Disk ...


Hello,

I am trying to recover MySQL databases (which were properly shut down) from an EXT4 formatted hard disk. I loaded the SystemRescueCD distro that you can get online and when running TestDisk I can see the partitions but I cannot recover said partitions because it tells me the structure is bad (any options here, by the way?)

With PhotoRec, I can recover parts of the MySQL Database but I cannot get the important *.MYD files because I guess PhotoRec doesn't have the signatures for that type of file.

So, any options I have at this point?

Thank you for your time.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-07-2012, 07:09 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,796

Rep: Reputation: 323Reputation: 323Reputation: 323Reputation: 323
Do some research on the use of e2fsck to repair damaged ext2/ext3/ext4 file systems. You may be able to return the partition to a mountable state.
 
Old 02-08-2012, 07:47 PM   #3
ckoeber
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bigrigdriver View Post
Do some research on the use of e2fsck to repair damaged ext2/ext3/ext4 file systems. You may be able to return the partition to a mountable state.
This has gotten me closer! Thanks so much.

So, now I used e2fsck and now everything that existed on that partition is in the "lost+found" directory on the root of the partition (at least I assume).

I am grepping in the lost and found directory but is there a better way to find stuff, especially the MySQL databases?

Thanks.
 
Old 02-08-2012, 09:36 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Quote:
Originally Posted by ckoeber View Post
(..) from an EXT4 formatted hard disk.
OK, databases shut down properly, but what happened to the disk? Do you have any backups? If yes, how old?


Quote:
Originally Posted by ckoeber View Post
I cannot recover said partitions because it tells me the structure is bad
Can't say w/o details but running testdisk with the "/debug /log" switches produces a log you can read and attach as plain text.


Quote:
Originally Posted by ckoeber View Post
With PhotoRec, I can recover parts of the MySQL Database but
Which parts?


Quote:
Originally Posted by ckoeber View Post
I cannot get the important *.MYD files because I guess PhotoRec doesn't have the signatures for that type of file.
That's because .MYD files contain the actual record data. If you had an old .MYD backup then in the most desperate situation you could use 'md5deep' in piecewise mode and compare hashes with those of recovered chunks in the hope of salvaging parts but the situation is complicated by write ops performed in the time between deletion and halting disks, file system direct and indirect block allocation, extfs journalling, database compression and what the bottom of this web log post explains about record deletion and reuse... Besides you do need the .frm to load the .MYD. Some more background info:
http://forge.mysql.com/wiki/MySQL_Internals_MyISAM
http://forge.mysql.com/wiki/MySQL_In...s_File_Formats
http://lists.mysql.com/internals/34752


Quote:
Originally Posted by ckoeber View Post
now I used e2fsck and now everything that existed on that partition is in the "lost+found" directory on the root of the partition (at least I assume).
I'm happy to see it worked for you as I would never have suggested using e2fsck w/o creating a disk image first. Running fsck tries to reorder what was already in disarray and IMNSHO allowing write ops on a file system slotted for recovery is a mortal sin.
 
2 members found this post helpful.
Old 02-09-2012, 12:34 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,446

Rep: Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068
Quote:
Originally Posted by unSpawn View Post
... and IMNSHO allowing write ops on a file system slotted for recovery is a mortal sin.
Hard to argue.
Even Ted Ts'o (the ext[234] maintainer) has come around. It used to be you couldn't stop the (potentially bad) journal be run even on a ro mount. Now at least you have the option of not running it - although I wonder how many people know ...
 
1 members found this post helpful.
Old 02-09-2012, 03:44 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Quote:
Originally Posted by syg00 View Post
Now at least you have the option of not running it - although I wonder how many people know ...
Hmm. Maybe in another language the anagram of "-o ro,norecovery,noload" is "I did read the manual"? ;-p
 
Old 02-09-2012, 03:05 PM   #7
ckoeber
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
OK, databases shut down properly, but what happened to the disk?
The disk was a virtual harddrive that was originally on a failed RAID array. I recovered the file after originally needing to get the RAID array back online.

Quote:
Do you have any backups? If yes, how old?
Yes, but the backups are incomplete due to being poorly configured. I won't be able to recover everything I need from it.

Quote:
Can't say w/o details but running testdisk with the "/debug /log" switches produces a log you can read and attach as plain text.
The file has been attached to this post.

Quote:
Quote:
With PhotoRec, I can recover parts of the MySQL Database but
Which parts?
Just the "frm" and "MYI" files. NOT the MYD files...

Quote:
I'm happy to see it worked for you as I would never have suggested using e2fsck w/o creating a disk image first. Running fsck tries to reorder what was already in disarray and IMNSHO allowing write ops on a file system slotted for recovery is a mortal sin.
That actually was OK since I copied the original virtual disk to a safe location and ran this operation on a copy of the virtual disk in question.

I still have the original VHD file so I can try something different if, based on what I wrote, I should do something else.

Thanks so much for the help thus far.
Attached Files
File Type: log testdisk.log (3.0 KB, 1 views)
 
Old 02-09-2012, 03:09 PM   #8
ckoeber
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Also, as a addition to what I wrote, PhotoRec is recovering a lot of stuff from the old system but because it doesn't have all of the MySQL file signatures I don't believe it is recovering the MySQL database files in one block.

If anyone knows a tool that can do what PhotoRec does but recover MySQL files I would be glad to get it! I believe it would be successful if I had something like that.
 
Old 02-09-2012, 06:16 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Quote:
Originally Posted by ckoeber View Post
the backups are incomplete due to being poorly configured.
I'm sorry for the qustions but anything that isn't clear should be explained. Incomplete in what way? Can you at least piece-wise hash the old .MYD and see what percentage of the file can be pinpointed on the disk?
 
Old 02-10-2012, 06:44 PM   #10
ckoeber
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
I'm sorry for the qustions but anything that isn't clear should be explained. Incomplete in what way? Can you at least piece-wise hash the old .MYD and see what percentage of the file can be pinpointed on the disk?
Incomplete in that I backed up only parts of the database (certain tables) and not the whole thing. The actual complete backup I can go to is well over a few months old so that isn't an option.
 
Old 02-12-2012, 10:55 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Maybe there's something at http://www.linuxquestions.org/questi...8/#post4600351 you could use.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't see files/folder on a formatted ext4 hard drive. rssn6 Debian 21 03-06-2012 07:36 PM
Debian squeeze will not show free and used disk space on EXT4 formatted hard drives sillas2001 Debian 5 03-06-2011 07:56 AM
USB DISK formatted ext4 not working kujirasan Linux - Hardware 9 02-09-2011 12:06 PM
Recovering mySQL database... Skillz Linux - Software 8 03-21-2009 06:16 PM


All times are GMT -5. The time now is 01:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration