3

Okay, I have to admit, that I derped up. I've exported a database from a to-be-reinstalled server and didn't check that file.

Now, that I try to import it, I've discovered something very strange, the file was supposed to be GZIP compressed, yet it cannot be compressed, so I open it up in Notepad++ and I see that it's not compressed. BUT when I try to import it as plain SQL i discover something more strange, somewhere in the middle of the file starts a byte stream.

Looks like phpmyadmin derped up the export somehow. Here you can see that file.

Has anyone exprienced something like this? Is there any way to recover such file?

It's not a very imporatant database, It could be recreated within couple of hours, plus I can restore it from off-site backup. BUT probably there will be someone who doesn't make regular data backups (you really should!), since I haven't seen anything like this on the Internet, I'm sharing it here, maybe somebody knows what could have caused it, how to fix it and how to recover such files.

Enbyted
  • 33
  • 6
  • The link to the file is missing... – gxx Dec 20 '15 at 00:21
  • @gf_ I'm sorry, apperently the way links work in SE markdown changed and I used standard markdown syntax which seems to not generate links properly (like the mini-markdown in comments). I fixed it! – Enbyted Dec 21 '15 at 00:54

1 Answers1

2

I had the same issue last night and was able to solve it. You'll need the gzrt package to repair the gzip. Here's how to fix it:

  1. Copy the beginning plaintext portion of your database.sql.gz file to a new file called database.sql
  2. Run gzrecover database.sql.gz
  3. Append the contents of database.sql.recovered into database.sql

You might have to manually replace a couple of characters.

See this issue for more info on why it happened.

ktross
  • 136
  • 2
  • Thank you, I just checked that and I can confirm that it works! There were very few glitches in the file, easy to catch with mysql errors. That might save someone's life someday, still, the best advice and answer is to check your backups! – Enbyted Jan 02 '16 at 11:10