The ESEUTIL command in Exchange Server 2007
Exchange Server 2007 continues the Exchange family’s tradition of using the Extensible Storage Engine database technology to store critical information, including users’ mail, contacts and calendar entries, as well as the contents of public folders. And while Exchange’s own database maintenance activities usually do a great job of keeping these databases running in top shape, sometimes the Exchange administrator is called upon to perform more hands-on maintenance, and the tool of choice for this is ESEUTIL.
Databases using the extensible storage engine do so because this database format is optimized for random reads and writes, unlike MS SQL which is great at random reads, but prefers contiguous writes. Each night, Exchange performs what is called online database maintenance. During online maintenance, Exchange performs a checksumming operation on each database to ensure its integrity, and then does an online defragmentation to optimize the performance. This will be scheduled automatically for after hours, but can be set by the Exchange administrator to specific times to support specific business needs. As long as this maintenance runs successfully each night, the database health is confirmed and there is nothing else the admin needs to do as part of regular database care and feeding. However, there are times when this automatic process fails, or when the database requires more direct intervention. This is where the ESEUTIL comes into play. ESEUTIL can perform database verification, modifications, and repairs as necessary.
The ESEUTIL is a command line utility, and requires administrative rights to Exchange and for each database that will be checked or repaired. The binary, eseutil.exe, is stored by default in C:\Program Files\Microsoft\Exchange Server\Bin. When you use ESEUTIL, you have to take the target database offline, though typically it’s already offline when you realize you need to do this.
Important note: Each version of Exchange comes with a version specific eseutil.exe binary. Do not attempt to use the ESEUTIL from one version of Exchange to repair a database on another version.
ESEUTIL, while very powerful, can be run against only one database at a time. As a command line tool, it uses switches to specify the action or actions to take against the target database. The format of the command is:
eseutil /switch or switches <database name> [options]
Here is a table with the most frequently used ESEUTIL switches:
| switch | mode | description |
| /D | defragment | Performs an offline defragmentation of the database, optionally overwriting the original database. This discards empty pages and rebuilds indexes. |
| /P | repair | Repairs a corrupt database by fixing individual tables, which abandons the relationship between tables. Mailbox and public folder databases will then need their table links repaired by using the ISINTEG tool. |
| /C | restore | Shows restore log files and handles recovery from legacy online backups. |
| /R | recovery | Replays transaction logs to restore a database or bring an older copy up to date. |
| /G | integrity | Verifies the logical integrity of a database at the page level. |
| /M | file dump | Displays the headers, space, and metadata for databases, log files, and checkpoint files. |
| /K | checksum | Verifies the checksum on all database pages, logs and checkpoints. |
| /Y | Copy file | Used to copy very large files quickly. |
Let’s look at some of the most common reasons to use ESEUTIL, and how to do it.
Defragmenting a database
Say you just got rid of a significant amount of information in your database because you moved several larger mailboxes to a new database on another server. The original database contains much less information, but still takes up the same amount of space. Once the retention period has passed, you can reclaim that space by performing an offline defragmentation.
- Make sure you have a good backup, and are prepared to do this during a maintenance window.
- Notify users that their mailboxes will not be available during this time.
- Ensure that the volume containing the database has at least 110% of the original database’s size in free space. If the database you are going to defragment is 100GB in size, you need at least 110GB free to perform the defrag.
- Log onto the mailbox server as an Exchange admin.
- Dismount the database.
- Open a command prompt and change to the directory that contains eseutil.exe.
- Run the following command to defragment the database named usermailboxes.
eseutil /d “usermailboxes.edb” [enter]
This can take a few hours to complete. Fortunately you will see a progress bar so you know that it is still working, and can estimate how long it will take to complete. Once it is done, it will confirm the new database, delete the old one, and rename the new one to match the original name. - Mount the new database and confirm you can access it.
- You must complete a full backup of the new database immediately, as you will not be able to use any log files from the original database to recover this new one.
Repairing a database
If a database corrupts due to a power failure, disk crash, etc., you can repair it with ESEUTIL. Unfortunately, this will result in some amount of data loss, and requires you to repair the integrity of the database using ISINTEG, so do not count on this process as a replacement for good backups, and consider implementing CCR databases to provide fault tolerance.
- Dismount the database if it has not already dismounted.
- Open a command prompt and change to the directory that contains eseutil.exe.
- Run the following command to defragment the database named usermailboxes.
eseutil /p “usermailboxes.edb” [enter]
This can take a few hours to complete. Fortunately you will see a progress bar so you know that it is still working, and can estimate how long it will take to complete. - Now run the ISINTEG tool, repeating the process until no further errors are reported.
isinteg –s usermailboxes –fix –test alltests [enter] - Defragment the repaired database using the steps in the first part of this article.
If the ESEUTIL command throws an error, you may not be able to run a complete recovery. There is a good reference for those error codes at this TechNet article.
The ESEUTIL is a very powerful tool for Exchange admins, but it is not a silver bullet. Having confirmed backups on hand, and implementing CCR databases, is the best way to minimize the chance of data loss.


Thanks for the article. Offlate I am facing a situation in CCR when logshipping fails and passive node database does not update. Updatestoragegroup works only in lab… it never worked in production with databases above 300GB.
I end up taking 3-4 scheduled downtime, taking services offline , copying database from active node to passive node, removing log files, chkpoint files and then mounting the database.
I really am not sure what is the best alternative to avoid downtime.
Appreciate any help in this regard.
Cheers,
Shyam Madeti