Friday, March 10, 2023

Exchange Server Defrag

Note: Some of these commands can be quite lengthy and therefore, will vary in the time to complete.

After any of the steps if the database shows as "Clean" when you check the status with the /mh command, then you can try to mount the DB again. If the DB is shows as "Dirty Shutdown" then keep going with the steps below.

1. Eseutil /mh database file path   - this checks the status of the DB

If the output shows "Dirty Shutdown" then you need to repair it- see below 

Example: eseutil /mh D:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb

2. Soft Recovery: Eseutil /r d:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb - note this only works if minimal corruption. Then run this again to check the status  --   eseutil /mh D:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb

3.If the above did not work then proceed to Hard Recovery: Eseutil /p D:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb

after it completes run status again Eseutil /mh D:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb

 4. Also a defrag may be needed if so Eseutil /d

You should run this command with a temp location so you don't run out of room. Designate a temp location that hes enough space to acommdata the database temp file. 

Example: Eseutil /d D:\Program Files\Exchange Server\Databases\Mailbox1\Mailbox1.edb /t e:\Temp\Temp1.edb

Note: To be safe the temp file should be two times the amount of the size of the database. In other words if the DB is 100GB it is best to have the temp file go to a location that has 200GB available. Otherwise, the command will not complete because it does not have enough space to work and complete the task.