An unexpected server outage, storage disconnect, or hardware failure can leave an on-premises Microsoft Exchange Server database in an unmountable, corrupted state. When Database Availability Group (DAG) replication fails to auto-failover, or when standalone mailbox databases suffer storage corruption, systems administrators must act swiftly to restore services without data loss.
In this updated runbook (fully validated for Exchange Server Subscription Edition (SE), Exchange Server 2019, and Exchange 2016), we walk through the exact, battle-tested procedure to restore a mailbox database from a full VSS backup, replay all uncommitted transaction logs up to the point of failure using Eseutil /r, and safely bring the database back into Clean Shutdown state.
Understanding ESE Database States: Clean vs. Dirty Shutdown
The Extensible Storage Engine (ESE) relies on a write-ahead transaction logging mechanism. Data is committed to memory and written sequentially to transaction logs (.log) before being flushed to the database file (.edb).
- Clean Shutdown (
State: Clean Shutdown): All cached database transactions have been flushed from memory and transaction logs into the.edbfile. The internal database header detachment flag is set to zero (0x0). A database in Clean Shutdown can be mounted immediately or moved across servers. - Dirty Shutdown (
State: Dirty Shutdown): The database was interrupted before all outstanding operations in the transaction log stream were committed to the.edbfile. The header points to a range of required log generations (Log Required: e.g., 2400-2415). You cannot mount a database in Dirty Shutdown.
Phase 1: Immediate Triage & Safe Log Preservation
Before restoring any files from backup, preserve the live log directory immediately. When an Exchange server crashes, the most recent emails exist in the live log files (E0000001A.log through E00.log). If your backup software overwrites this directory, that data is permanently lost.
1. Copy Live Transaction Logs to a Safety Directory
Open an elevated PowerShell prompt and copy the existing transaction logs to a dedicated staging drive:# Example: Mailbox Database DB01 on Exchange SE / 2019
$LiveLogDir = "F:\ExchangeData\DB01\Logs"
$BackupHold = "E:\RecoveryStaging\LiveLogs_BackupHold"
New-Item -ItemType Directory -Path $BackupHold -Force
Copy-Item -Path "$LiveLogDir\*.log" -Destination $BackupHold -Verbose
Copy-Item -Path "$LiveLogDir\*.jfm" -Destination $BackupHold -Verbose
2. Verify Current Database Header State
RunEseutil /mh against the existing .edb file:
Eseutil /mh "F:\ExchangeData\DB01\DB01.edb"
Locate the following critical fields in the output:
State: Dirty Shutdown
Log Required: 2450-2462 (0x992-0x99e)
Log Committed: 2463 (0x99f)
Log Previous Gen: 2449 (0x991)
- If
Stateis Dirty Shutdown, the database cannot mount until log generations0x992through0x99eare replayed. - Note the log prefix (typically
E00,E01,E02).
Phase 2: Restoring the Database File from Backup
When the live .edb file is corrupted beyond repair (e.g., storage I/O errors or unreadable disk sectors):
- Dismount the Database:
Dismount-Database -Identity "DB01" -Confirm:$false
- Restore Only the EDB File:
Using your enterprise backup software (Azure Backup, Veeam, Commvault, or Windows Server Backup), perform a targeted file-level restore of only the .edb file from the latest full backup.
- Inspect the Restored EDB File:
Run Eseutil /mh on the freshly restored .edb file. A restored full backup .edb file will always be in Dirty Shutdown state, waiting for the backup-associated transaction logs to be rolled forward.
Phase 3: Executing Soft Recovery via Eseutil /r
Soft recovery replays the transaction log sequence into the database, committing transactions, rolling back incomplete operations, and stamping the database header as Clean Shutdown.
The Anatomy of Eseutil /r
ESEUTIL /r <LogPrefix> /L "<PathToLogs>" /s "<PathToSystemCheckpoint>" /d "<PathToDatabaseDirectory>" /i
<LogPrefix>: The 3-character database log stream prefix (e.g.,E00,E01)./L: Absolute directory containing the transaction log files./s: Absolute directory where checkpoint files (*.chk) reside./d: Directory containing the target.edbfile./i: Ignores missing database mismatch errors if dealing with multi-database log streams.
Executing the Command
cd /d "F:\ExchangeData\DB01\Logs"
Eseutil /r E00 /L "F:\ExchangeData\DB01\Logs" /s "F:\ExchangeData\DB01\Logs" /d "F:\ExchangeData\DB01" /i
During execution, Eseutil processes three distinct phases:
- Log Redo Phase: Scans the log stream forward and replays uncommitted database pages.
- Log Undo Phase: Rolls back any operations that were in-flight and uncommitted when the crash occurred.
- Clean Header Stamp: Updates the database detachment flag to
0x0.
Microsoft(R) Exchange Server Database Utilities
Version 15.02 (Exchange Server SE / 2019)
Initiating RECOVERY mode...
Logfile base name: E00
Log files path: F:\ExchangeData\DB01\Logs
System files path: F:\ExchangeData\DB01\Logs
Database Directory: F:\ExchangeData\DB01
Performing soft recovery...
10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
|----|----|----|----|----|----|----|----|----|----|
...................................................
Operation completed successfully in 84.12 seconds.
Phase 4: Validating Clean Shutdown & Mounting the Database
Before mounting, confirm the database header has transitioned to Clean Shutdown:
Eseutil /mh "F:\ExchangeData\DB01\DB01.edb" | findstr /i "State: Log"
Expected Output:
State: Clean Shutdown
Log Required: 0-0 (0x0-0x0)
Once confirmed:
# Mount the recovered database
Mount-Database -Identity "DB01"
# Verify healthy database status
Get-MailboxDatabaseCopyStatus -Identity "DB01" | Format-Table Name, Status, ContentIndexState
Alternative Approach: Restoring via Recovery Database (RDB)
If you only need to salvage a single deleted mailbox or mailbox folder without overwriting the live production database, restore the backup .edb into a Recovery Database (RDB):
# 1. Create the Recovery Database in Exchange Management Shell
New-MailboxDatabase -Recovery `
-Name "RDB01" `
-Server "EX01" `
-EdbFilePath "E:\RecoveryDB\DB01_Recovered.edb" `
-LogFolderPath "E:\RecoveryDB\Logs"
# 2. Allow file restore overwrites
Set-MailboxDatabase -Identity "RDB01" -AllowFileRestore $true
# 3. Mount the Recovery Database
Mount-Database -Identity "RDB01"
# 4. Extract data to a target mailbox
New-MailboxRestoreRequest `
-SourceDatabase "RDB01" `
-SourceStoreMailbox "Adele Vance" `
-TargetMailbox "[email protected]" `
-TargetRootFolder "Restored_Items"
# 5. Monitor restore completion
Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics
Summary Checklist for Exchange Administrators
- Triage First: Never delete or overwrite the live log directory before copying it offsite.
- Check State (
/mh): Note the required log generation range before attempting soft recovery. - Replay Cleanly (
/r): Use Eseutil soft recovery to achieve clean detachment (State: Clean Shutdown). - Avoid Hard Repair (
/p): Never runEseutil /punless soft recovery has completely failed and you are prepared to accept data loss. - Consider RDB: Use Recovery Databases (
New-MailboxDatabase -Recovery) for granular single-mailbox recovery.