Friday, 6 January 2012

Part 13 – Database repair on Exchange 2010 setup Multi-Tenancy

In the event of a database corruption you can use the Eseutil tool to repair it. It is best to run this from CMD as you can run it from Exchange shell but you get limited options.

First check the status of your database using Exchange shell. To do this run:

Get-MailboxDatabaseCopyStatus –Identity “Database name”

This will show you if the database is healthy and mounted. If you think the database is corrupt then there is a good chance it is not mounted.

Next you need to check the state the database shut down in. To do this run the following in CMD:

Eseutil /mh "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Databasename.edb"

Change the red to match the location and name of your database.

The output will look something like this:


If the status is Clean shutdown then we can try and remount the database, If not we need to bring it into a clean state.

Clean state:

Locate the log folder for the database and rename it and do the same with the database folder. Then recreate these folders so what you will have is 1 or 2 folders depending on if your database and logs are in the same place with nothing in them named the same as they were before. Then copy (not cut) the database from the database folder you just renamed and paste into the new folder.



Now try to remount the database using the following:

Mount-Database -Identity 'Databasename'

If it does not mount then we need to try and repair it.


Dirty State:

Locate the log folder for the database and rename it and do the same with the database folder. Then recreate these folders so what you will have is 1 or 2 folders depending on if your database and logs are in the same place with nothing in them named the same as they were before. Then copy (not cut) the database from the database folder you just renamed and paste into the new folder. In the old log folder copy all of the logs (.log) except the E00 log. So basically all the logs which are around 8 characters long. Paste these into the new log folder.

To check you have all the log files and that they are in a concurrent state run

Eseutil /ml “C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Log folder"

This will check them and hopefully you should get a list with OK next to each log

If these are not concurrent and you do not have the full logs these cannot be run





Database repair

Once you have followed the above steps you are ready to try a repair. I recommend running the following

eseutil /r E00 /d "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\database folder " /s "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\System files folder" /l "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Log files folder" /i /a


Change the text in red to match your file locations. If you are unsure about the system folder location chances are it will be the same as your log folder location.
In the database location only put the folder the database is in not the database file name.

If the database was in a clean shutdown state this should repair it. If it was in a dirty shutdown state and you have te ld logs in the log folder it will pay those logs and repair the database.

It’s probably wise at this point to defrag the database using the following command

Eseutil /d "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\database folder\Databasefile.edb"

Now try and mount the database again.

If this fails you can try a hard repair by using the following:
Eseutil /p "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\database folder\Databasefile.edb"

This will perform a hard recovery.

If the database is so corrupt it is un repairable please use a backup of the database file and replay the logs using


eseutil /r E00 /d "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\database folder " /s "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\System files folder" /l "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Log files folder" /i /a


If you do not have a backup of the logs I recommend using a hard drive recovery tool to see if you can retrieve a suitable version. I would recommend using a tool called r-studio as this worked for me.

When you remount a database without log files already present it creates new ones and changes the signature of the logs. From this point an older version of the edb file cannot be used as it has a different signature. To identify if the log signature and edb signature match use the following commands:

For logs
Eseutil /ml “C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Log folder\1 log filename.log"

For database

eseutil /mh “C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Database folder\Database.edb"

Change the red text again to match your location. The output will look like this

K:\sg1>eseutil /mh "mailbox database.edb"
Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 08.01
Copyright (C) Microsoft Corporation. All Rights Reserved.
Initiating FILE DUMP mode...
Database: mailbox database.edb
DB Signature: Create time:08/25/2008 22:54:52 Rand:4416518 Computer:
Log Signature: Create time:08/25/2008 22:54:50 Rand:4412688 Computer:
Operation completed successfully in 0.140 seconds.





L:\sg1>eseutil /ml e000000001a.log
Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 08.01
Copyright (C) Microsoft Corporation. All Rights Reserved.
Signature: Create time:08/25/2008 22:54:50 Rand:4412688 Computer:
1 k:\sg1\Mailbox Database.edb
Signature: Create time:08/25/2008 22:54:52 Rand:4416518 Computer:
Operation completed successfully in 0.60 seconds.




If the log signatures match then a repair is possible if not then you need to find a version of the edb file that does match the logs you want to replay.