Just sticking this here as a placeholder for myself. I’ve had the occasion to need to do offline defrags of the Exchange private store onto a different drive due to the drive where the private store having too little space. Microsoft has some great documentation on using the eseutil, but their scenarios don’t include scripts for automating or scheduling after hours offline defrags.
As I have to perform additional offline defrags, I’ll post more scripts that have been tested to work so you can simply drop the script in a directory and schedule it to run with the operating system.
eseutil /d /p "d:\program files\exchsrvr\mdbdata\priv1.edb" /t"Y:\exchdefrag\tempdfg.edb"
* Batch file for just doing a simple, in-place defrag (assuming you have enough disk space on the drive where the defrag is to take place):
eseutil /d /p "d:\program files\exchsrvr\mdbdata\priv1.edb"
ESEUTIL.exe command line switches:
DESCRIPTION: Maintenance utilities for Microsoft(R) Exchange Server databases
MODES OF OPERATION:
Defragmentation: ESEUTIL /d <database name> [options]
Recovery: ESEUTIL /r <logfile base name> [options]
Integrity: ESEUTIL /g <database name> [options]
Checksum: ESEUTIL /k <file name> [options]
Repair: ESEUTIL /p <database name> [options]
File Dump: ESEUTIL /m[mode-modifier] <filename>
Copy File: ESEUTIL /y <source file> [options]
Restore: ESEUTIL /c[mode-modifier] <path name> [options]
<<<<< Press a key for more help >>>>>
D=Defragmentation, R=Recovery, G=inteGrity, K=checKsum,
P=rePair, M=file duMp, Y=copY file, C=restore