Repairing an offline Exchange Mailbox Database
by Chris Hall/January 23, 2017
Even the best most well maintained Exchange Database can have issues from time. Best practices such as ensuring adequate disk space, online archives, quota and above all importance – backups as absolutely necessary. The best way to prevent database issues is to backup and attempt to steer away from any possible problems.
If you ever do get database issues, follow the below route to restore. This is what we’ve found as the best/fastest route. Note that it is intended to restore the Database with no data loss but also steps you through the worst case scenario of doing a full repair.
1. The first step with a corrupt Mailbox Database is to make a copy of your Database log files. These are all files (except your EDB database file) in the database directory. The reason for the copy is that this is a last resort (shown in step 5 below) in order to restore your database and replay unaltered log files so no data is lost.
2. Check your Exchange database health state by using the below command. Note that Exchange 2013/2016 can report a database is mounted in ECP even if that isn’t the case.
This will output some text on screen. You should look for the ‘state’ line that states either ‘Clean Shutdown’ or ‘Dirty Shutdown’.
3. To remove a dirty shutdown state, try running the below command:
4. If this works it should return your Database to a ‘Clean Shutdown’ state. Run the command shown in step 2 to check this.
5. If this doesn’t work, the next best step is restore from backup.
6. To replay log files correctly, navigate to your log files directory and move the E00.chk file to another folder. The checkpoint file will point to specific location in the logs to restore from. Deleting the file should start the replay process as log 1 and continue until complete.
7. Now run the below command to replay the log files. The log files should be your original copy of the log files copied back to their usual location.
8. Once complete run the command listed in step 2 of this process to check the State is now ‘Clean Shutdown’. If so mount the database and do some tests, everything should be ok.
9. If you get ‘Dirty Shutdown’ still the last option is running a full EDB repair. Note that doing this will not replay logs files so anything not already in the database will be lost. This is by far a last resort process. In some cases data loss may be minimal and staff using Outlook with Cached Mode enabled may not even notice. Staff without Outlook/Cached mode could loose bulk amounts of emails.
Run the below command to do a full repair. Note that the repair process could take anywhere from 15 minutes to multiple days depending on the size of the database.
10. Once complete, run the command in step 2 once more and check for “Clean Shutdown” in the status. If so mount the database and do some tests.
11. Do a full system backup of your Exchange server and Databases immediately after this process.
Note: If you performed a full repair (/p) Microsoft strongly recommend creating a new blank Exchange database and moving all mailboxes in the repaired EDB to the new database. This avoids possible further corruptions and potential downtime/loss of data.