Defragging Exchange in 4 easy steps!

It’s easy enough to search the web for various instructions on how to do an offline defrag of your Exchange database. With SBS, an online defrag occurs every morning. However, that does not actually reduce the size of the .edb/.stm files. Performing an offline defrag is recommended, for example, after you have finished deleting a lot of old emails or purging old mailboxes.

Here are the four basic steps I follow:

1. Backup
You can never have enough backups. I will first use NTBackup to create a full backup of the Exchange database. I will usually do the backup to a file rather than tape, and put it on a separate partition that where my Exchange database is located.

2. Dismount
Go into ESM and dismount your Exchange partitions. Drill down ESM > Servers > Your Server > First Storage Group. Right click on the Mailbox store, and click Dismount Store. Then right click on the Public Store, and click Dismount Store.

3. Defrag
Open up a command window (Start > Run > Cmd). Assuming your Exchange partition is located on your C: drive, type the following commands:

Step 1.  cd \Program Files\Exchsrvr\mdbdata
Step 2.  dir priv1* pub1*
Step 3.  ..\bin\eseutil /d pub1.edb
Step 4.  ..\bin\eseutil /d priv1.edb
Step 5.  dir priv1* pub1*

Step 1 simply points you to the subdirectory where the priv1* and pub1* files exist,  Step 2 lists the sizes of your files. Write these down to compare with the size afterwards. Step 3 & 4 performs your actual inplace defrag of your public and private stores. I generally do the public store first, just because I have less to lose if I screw up my public store. Also, since the public store is usually smaller, it takes less time. The private store, could very well take up to an hour for every 5GB of the priv1 store.
Step 5 lets you compare your new file sizes to your old sizes.

4. Remount & Backup
Now go back to ESM and remount your public and private stores! Most best practices suggest doing another full backup immediately. Most of the time, I wait until my scheduled backup runs. But that’s your call.

3 thoughts on “Defragging Exchange in 4 easy steps!

  1. I have a priv1.edb file of 15 Go and I did a defrag 4 times but the file is still 15 Go and when I sum the mailboxes size in system manager I found 9 Go pls can you help me ?

  2. Do you know how you can have the templog created in another drive? The C drive is not large enough and I would like to put it in the D drive.

Leave a Reply

Your email address will not be published. Required fields are marked *