Using ESEUTIL to recover and repair exchange databases

Vraag:

Using ESEUTIL to recover and repair exchange databases with dirty shutdown state
Tags: eseutil, dirty, shutdown state, exchange, database, 2003, 2007, isinteg

Antwoord:

here are plenty of guides on using eseutil but getting the parameters right always seems to be a case of trial an error, so here’s a quick howto:

1) Copy all the original database and log files to somewhere safe. Then also copy them into a working directory. Eseutil will modify the files in situ so if it goes wrong you don’t want your original files modified.

You need to have a copy of the database files (*.edb and *.stm) plus the transaction logs (Exx*.log where xx is a number relating to the information store). The location of the files is available from exchange system manager, but you really should know where they all are anyway.

I’m going to assume the temp directory for the database files is e:\temp\data and they’re called exchdb.edb, exchdb.stm. If they reside in the 1st storage group, the transaction logs will be called E00.log (this is the most recent base file) and E00xxxx.log etc (these are the old logs). Lets assume these are copied to e:\temp\logs. You need to replace these with your own paths/filenames of course.

2) Check the database state and expected log files with

eseutil.exe /mh e:\temp\data\exchdb.edb

The output will show a line State: which will be either clean or dirty shutdown. If it’s clean, then you don’t need this article :)

It will also show which logs are required e.g. which hadn’t yet been played into the database when the dirty shutdown occured. If you have any missing then you will have lost email. This generally only occurs if you lost a log drive and have replicated copies of the logs you can use.

3) “Recover” the database. This replays missing transaction logs into the database file – run:

eseutil.exe /r E00 /d”e:\temp\data\exchdb.edb”

You might receive an error that there is an outstanding database attachment. In this case use the /i switch in the command

eseutil.exe /r E00 /d”e:\temp\data\exchdb.edb” /i

4) recheck the database state with the command in 2). If it still shows dirty shutdown you need to repair the database with:

eseutil /p e:\temp\data\exchdb.edb

5) Recheck the database once more and it should show clean shutdown. At this point you should defrag the database

eseutil /d e:\temp\data\exchdb.edb

6) The file is now in a clean state and is ready to be put back into exchange so copy it back to the original location on your exchange server but don’t yet mount the file. The last step before mounting the file is to get rid of any remaining errors using isinteg.exe. This tool requires the database to be in the original location on the original exchange server. It needs to be run several times until it no longer reports any errors.

7) Once the database file has no more errors you can now remount it in exchange.

USING HARD RECOVERY

eseutil /r /a e00 /d “C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\” /s “C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group”

Then

eseutil /p “C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\Mailbox Database.edb”

Where “C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group” and “Mailbox Database.edb” were the names of my database directory and database file respectively.

The first, recovers the database from the existing log files and the second performs a repair on the database for inconsistencies.