Exchange: Recovering a Database from Dirty Shutdown (the Easy Way)

In testing (and production), we invariably run into problems where the database will be in a 'bad state'. In my case, I pulled Store service out from under it (disabled and stopped the service) and this caused the database to go into dirty shutdown:

eseutil.exe /mh "C:\Databases\EMEA-SWEEX15-01 Store 001\EMEA-SWEEX15-01 Store 001.EDB"

Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 15.00
Copyright (C) Microsoft Corporation. All Rights Reserved.

Initiating FILE DUMP mode...
         Database: C:\Databases\EMEA-SWEEX15-01 Store 001\EMEA-SWEEX15-01 Store 001.EDB

DATABASE HEADER:
Checksum Information:
Expected Checksum: 0x65021d61
  Actual Checksum: 0x65021d61

Fields:
        File Type: Database
         Checksum: 0x65021d61
   Format ulMagic: 0x89abcdef
   Engine ulMagic: 0x89abcdef
 Format ulVersion: 0x620,20
 Engine ulVersion: 0x620,20
Created ulVersion: 0x620,20
     DB Signature: Create time:05/05/2014 13:08:25.805 Rand:306694709 Computer:
         cbDbPage: 32768
           dbtime: 10263756 (0x9c9ccc)
            State: Dirty Shutdown
     Log Required: 12131-12194 (0x2f63-0x2fa2)
    Log Committed: 0-12195 (0x0-0x2fa3)
   Log Recovering: 12195 (0x2fa3)
  GenMax Creation: 10/14/2014 07:55:56.052
         Shadowed: Yes
       Last Objid: 56187
     Scrub Dbtime: 0 (0x0)
       Scrub Date: 00/00/1900 00:00:00
     Repair Count: 0
      Repair Date: 00/00/1900 00:00:00.000
 Old Repair Count: 0
  Last Consistent: (0x263B,8B,19C) 08/28/2014 08:55:57.153
      Last Attach: (0x263C,2,268) 08/28/2014 08:55:57.294
      Last Detach: (0x0,0,0) 00/00/1900 00:00:00.000
    Last ReAttach: (0x2DEA,2,0) 10/11/2014 04:46:44.436
             Dbid: 1
    Log Signature: Create time:05/05/2014 13:08:25.649 Rand:2111075525 Computer:
       OS Version: (6.2.9200 SP 0 NLS ffffffff.ffffffff)

Previous Full Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Incremental Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Copy Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Differential Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Current Full Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Current Shadow copy backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

     cpgUpgrade55Format: 0
    cpgUpgradeFreePages: 0
cpgUpgradeSpaceMapPages: 0

       ECC Fix Success Count: none
   Old ECC Fix Success Count: none
         ECC Fix Error Count: none
     Old ECC Fix Error Count: none
    Bad Checksum Error Count: none
Old bad Checksum Error Count: none

  Last checksum finish Date: 10/14/2014 08:02:23.469
Current checksum start Date: 00/00/1900 00:00:00.000
      Current checksum page: 0

Operation completed successfully in 0.187 seconds.

Using eseutil (and assuming the log is still available) we can recover from such a state like the following:

eseutil /r "E01" /l "C:\Databases\EMEA-SWEEX15-01 Store 001\Logs" /d "C:\Databases\EMEA-SWEEX15-01 Store 001"

Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 15.00
Copyright (C) Microsoft Corporation. All Rights Reserved.

Initiating RECOVERY mode...
    Logfile base name: E01
            Log files: C:\Databases\EMEA-SWEEX15-01 Store 001\Logs
         System files: <current directory>
   Database Directory: C:\Databases\EMEA-SWEEX15-01 Store 001

Performing soft recovery...
                      Restore Status (% complete)

          0 10 20 30 40 50 60 70 80 90 100
          |----|----|----|----|----|----|----|----|----|----|
          ...................................................

Operation completed successfully in 13.140 seconds.

And, once we've completed said step, we can verify if the database is - indeed - in clean shutdown:

eseutil.exe /mh "C:\Databases\EMEA-SWEEX15-01 Store 001\EMEA-SWEEX15-01 Store 001.EDB"

Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 15.00
Copyright (C) Microsoft Corporation. All Rights Reserved.

Initiating FILE DUMP mode...
         Database: C:\Databases\EMEA-SWEEX15-01 Store 001\EMEA-SWEEX15-01 Store 001.EDB

DATABASE HEADER:
Checksum Information:
Expected Checksum: 0x758dd2a3
  Actual Checksum: 0x758dd2a3

Fields:
        File Type: Database
         Checksum: 0x758dd2a3
   Format ulMagic: 0x89abcdef
   Engine ulMagic: 0x89abcdef
 Format ulVersion: 0x620,20
 Engine ulVersion: 0x620,20
Created ulVersion: 0x620,20
     DB Signature: Create time:05/05/2014 13:08:25.805 Rand:306694709 Computer:
         cbDbPage: 32768
           dbtime: 13412964 (0xccaa64)
            State: Clean Shutdown
     Log Required: 0-0 (0x0-0x0)
    Log Committed: 0-0 (0x0-0x0)
   Log Recovering: 0 (0x0)
  GenMax Creation: 00/00/1900 00:00:00.000
         Shadowed: Yes
       Last Objid: 66933
     Scrub Dbtime: 0 (0x0)
       Scrub Date: 00/00/1900 00:00:00
     Repair Count: 0
      Repair Date: 00/00/1900 00:00:00.000
 Old Repair Count: 0
  Last Consistent: (0x2FA4,1,31) 10/14/2014 08:10:54.954
      Last Attach: (0x263C,2,268) 08/28/2014 08:55:57.294
      Last Detach: (0x2FA4,1,31) 10/14/2014 08:10:54.954
    Last ReAttach: (0x2DEA,2,0) 10/11/2014 04:46:44.436
             Dbid: 1
    Log Signature: Create time:05/05/2014 13:08:25.649 Rand:2111075525 Computer:
       OS Version: (6.2.9200 SP 0 NLS ffffffff.ffffffff)

Previous Full Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Incremental Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Copy Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Previous Differential Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Current Full Backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

Current Shadow copy backup:
        Log Gen: 0-0 (0x0-0x0)
           Mark: (0x0,0,0)
           Mark: 00/00/1900 00:00:00.000

     cpgUpgrade55Format: 0
    cpgUpgradeFreePages: 0
cpgUpgradeSpaceMapPages: 0

       ECC Fix Success Count: none
   Old ECC Fix Success Count: none
         ECC Fix Error Count: none
     Old ECC Fix Error Count: none
    Bad Checksum Error Count: none
Old bad Checksum Error Count: none

  Last checksum finish Date: 10/14/2014 08:02:23.469
Current checksum start Date: 00/00/1900 00:00:00.000
      Current checksum page: 0

Operation completed successfully in 0.235 seconds.

And, now, the database is safe to mount, again.