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
- Details
-
Written by Nicolas Buache
-
Created on Sunday, 08 January 2012
-
Last Updated on Sunday, 08 January 2012
-
Hits: 1205