Sunday, March 1, 2015

Recover a MySQL database with only bin-log file

Here is the CATASTROPHE:




We are working in our company with a web application for test management: TestLink.
One team was working on it for more than 1 month till now. Yesterday, another team wanted to start using testLink too, so i was asked to install it for them.



The installation was made on the same server where the first TestLink was running, i'm using WampServer.2.0 in which i run testLink, so i started installing it again, unfortunately on the same WampServer.. i was a little bit tired, and i didn't mentioned in the installation that I was giving the second TestLink the same database name as the first one.. installation succeeds... But WAIT!! all data in the first database was LOST!! overwritten by an empty and new database..! I felt somebody is definitely going to kill me!



So i start googling, but since no database backup was made since the installation of the first TestLink.. i really felt i have no solution.. i tried running softwares to backup overwritten and accidentally removed files, that didn't help.. of course...



i found in this blog a story about MySQL binary logs, but looks like it's necessary to have at least one backup to restore lost data. In the configuration of my my.ini file, log-bin=mysql-bin line is uncommented and i can find files under mysql\data\ that looks like this: mysql-bin.00000x



I ran the mysqlbinlog command on one of them using: mysqlbinlog --start-datetime="2011-04-01 00:00:00" mysql-bin.000006, that made my screen look like a matrix one, i can recognize lines that looks like TestLink commands, the command seems to end successfully.. but no.. tables in the database stay unchanged, empty...




Am I missing something? is there a light of hope?



Please help..

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...