Login
Theme: Light Dark

How can I recover corrupt database file?

Tagged:

Home - Quora Link

  1. Restore your backup and turn on transaction journaling. I’m hoping that you’re not actually wanting to fix corrupt data. But if that’s what you’re trying to do then here’s that procedure:
    1. Figure out whether your corruption is at the data format level or the application level. If you can open the database in the built-in SQL console and run queries, then it’s your application that’s the problem.
    2. Work down to the source of the corruption. If it’s actual corruption, not just your application not liking the format, then this requires deep deep knowledge about the format of your database files and practically is in the realm of a specialist. Expect a thousand dollar bill at the minimum. Next time take better backups.
    3. If it’s application corruption, then the specific error your application is giving you should be helpful. If it’s not then you need to dive into the source code of the application to figure out what’s going wrong. Hopefully you at least have a line number where the error is being thrown.
    4. Once you’ve found the source, make the edits needed to make the database readable. This is now your new backup, keep it somewhere safe and move on to step 2.
  2. You have a working system again, but you haven’t figured out the source of the corruption. This is what transaction journaling is for. Monitor your application daily until the corruption recurs. Examine the journal and look for the offending query. Chances are it’s an update, insert, or delete. You need to figure out what about the stuff it’s inserting, updating or deleting is causing the application or database to break. Applications are far less robust than databases, so chances are it’s the application that just doesn’t like what it’s seeing.
  3. Correct the defect in the application source code that’s causing the issue.
  4. Turn off transaction journaling, continue to take regular backups, consider a regular procedure to test the backups with your application, there’s no better safeguard to making sure your backups are providing a safety net than actually restoring from them.