20.05.2012
Main Menu
Photo Gallery
Online Profiles
* * Google AdSense * *

Defrag Exchange DB

Go back to Knowledge Base

I wrote different scripts to defrag Exchange 2000 & 2003 DB. To defrag a database, it is required to have it offline with enough free disk space to complete the task (at least the current size of the DB).

 

The first solution is to stop MS Exchange Information Store service + Antivirus services + backup job, as the Exchange DB needs to be offline and stopping the Antivirus + backup job will increase the performances.

Be aware that, by stopping the Information Store, you will stop all Exchange databases hosted by this system. Running a backup before doing the maintenance is an excellent idea, in order to prevent any issue.

Defrag Script (batch job):

Net Stop "Microsoft Exchange Information Store"

Net Stop "Name of your Antivirus Service"

"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\pub1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm

"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm

"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv2.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm

"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv3.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm

"F:\Bin\eseutil.exe" /d "H:\Exchange Server\mdbdata\priv4.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm

Net Start "Name of your Antivirus Service"

Net Start "Microsoft Exchange Information Store"

 

The second solution is to dismount the databases one by one and stop the Antivirus services + backup job, as the Exchange DB needs to be offline and stopping the Antivirus + backup job will increase the performances.

By dismounting the databases one by one, this is reducing the maintenance time (downtime) for all DB. Running a backup before doing the maintenance is an excellent idea, in order to prevent any issue.

Defrag Script (batch job):

Net Stop "Name of your Antivirus Service"

Wscript C:\temp\dismount_db_pub1.vbs
"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\pub1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm
Wscript C:\temp\mount_db_pub1.vbs

Wscript C:\temp\dismount_db_priv1.vbs
"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm
Wscript C:\temp\mount_db_priv1.vbs

Wscript C:\temp\dismount_db_priv2.vbs
"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm
Wscript C:\temp\mount_db_priv2.vbs

Wscript C:\temp\dismount_db_priv3.vbs
"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm
Wscript C:\temp\mount_db_priv3.vbs

Wscript C:\temp\dismount_db_priv4.vbs
"F:\Bin\eseutil.exe" /d "G:\Exchange Server\mdbdata\priv1.edb" /t H:\TempDB\tempdfrg.edb /f H:\TempDB\tempdfrg.stm
Wscript C:\temp\mount_db_priv4.vbs

Net Start "Name of your Antivirus Service"

 

Dismount script (vbs):

Set oDB = CreateObject("CDOEXM.MailboxStoreDB")

strDB = "CN=DatabaseName,CN=StorageGroupName,CN=InformationStore,CN=ServerHostname,CN=Servers,CN=EU-EXCH,CN=Administrative Groups,CN=Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=ADDomain,DC=com"

oDB.DataSource.Open strDB
oDB.Dismount()

oDB.Mount()

 

Mount script (vbs):

Set oDB = CreateObject("CDOEXM.MailboxStoreDB")

strDB = "CN=DatabaseName,CN=StorageGroupName,CN=InformationStore,CN=ServerHostname,CN=Servers,CN=EU-EXCH,CN=Administrative Groups,CN=Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=ADDomain,DC=com"

oDB.DataSource.Open strDB
oDB.Mount()

 

Details regarding batch scripts:

F drive: Location of the Exchange executable file (eseutil.exe)

G drive: Location of the Exchange database

H drive: Location of temporary location (with enough free space)

 

I hope these scripts will help you to maintain your existing Exchange servers. De-fragmenting databases could help to increase performances. When adding data (emails, mailboxes...), the database size is growing. When we delete data, the database size does not reduce, it keeps "blank" space. By de-fragmenting the database, it allows to clean these "blank" spaces and reduce the database size.

Go back to Knowledge Base




* * * * * Did you like this page ? - - - Post it on your Facebook ! * * * * *
* * * * * Google Custom Search * * * * *
Last Updates
Help
Translate by Google
English French German Italian Portuguese Russian Spanish Swedish
Login Form

* * Current URL * *
Mobile Barcode
Visitors Stats
56.6%United States United States
10.8%Switzerland Switzerland
6%Canada Canada
4.8%India India
3.6%United Kingdom United Kingdom
3.6%Australia Australia
2.4%France France
2.4%Portugal Portugal
1.2%Indonesia Indonesia
1.2%Singapore Singapore

Stats by ExtraWatch