Fix it now
Microsoft publishes -1216 as JET_errAttachedDatabaseMismatch: an outstanding database attachment was detected at the start or end of recovery, but the database is missing or does not match the attachment information. Files have been mixed, moved or restored from different points. Nothing is necessarily damaged.
Get-MailboxDatabase DB01 | Format-List Name,EdbFilePath,LogFolderPath
Get-MailboxDatabaseCopyStatus DB01 | Format-Table Name,Status,CopyQueueLength,ReplayQueueLength
- Copy the database, the whole log folder and the checkpoint file somewhere else before you run anything. Do not reach for a repair tool.
- Compare what Exchange believes the paths are with what is actually on disk. A file that is simply not where the database object says it is produces -1811, which is a path problem, not a damaged database.
- Check whether the log folder holds more than one log prefix. Two databases pointed at one log directory is the classic way to reach this error.
- If you get a file access error instead, find what is holding the file: stop the backup agent, run vssadmin list writers, and check the antivirus exclusions.
- Where a healthy copy exists in a DAG, activate it and reseed the mismatched one rather than reconciling files by hand.
Move-DatabasePath cannot be run against a replicated database at all. Microsoft’s documented sequence is to remove every copy, move the path, then add the copies back.
If the database mounts on the corrected paths, you are done. If not, the next section separates the four codes in this family by which layer they come from.
Why it happens
When a database is created it starts a log stream, and that stream carries a signature and a prefix. The database records which stream it belongs to and how far replay has reached; the logs record which databases were attached when they were written. Recovery cross-checks the two before replaying anything, because a log generation written for a different database describes changes to pages that mean something else entirely here. Microsoft’s wording for -1216 is precisely that mismatch: an attachment was detected but the database is missing or does not match the attachment info.
There are only a few ways to arrive at it. Two databases were pointed at the same log folder, so two streams are interleaved in one directory. A restore returned the database from one point and logs from another. Files were moved by copying them and editing properties instead of using the supported move. Or a copy was seeded, interrupted, and then partly overwritten by hand.
The neighbouring codes describe simpler failures on the same path, and Microsoft publishes all three. -1811 is JET_errFileNotFound, the file was not found. -1032 is JET_errFileAccessDenied, the file cannot be accessed because it is locked or in use. -1022 is JET_errDiskIO, there is a disk IO error, which is a hardware conversation rather than a database one.
The log folder holds more than one stream, or the wrong one
You have this one if The log directory contains generations with more than one prefix, or the stream does not belong to this database.
- Separate the streams. Each database should own its own log directory, and no other database should ever write into it.
- Move the foreign generations to a holding folder rather than deleting them, in case they belong to a database you still need.
- Confirm the remaining stream belongs to this database before running recovery again with explicit paths.
If you cannot tell which stream belongs where, match them on the database file rather than guessing. Guessing here is how one recoverable database becomes two unrecoverable ones.
Only part of a backup set was restored
You have this one if The database file was restored, or the logs were, but not both from the same point in time.
- Restore the complete set again, database and logs together, into a folder well away from the production paths.
- Let the backup product run its own recovery if it offers to. Its restore process understands its own log handling better than a manual replay does.
- Only after the restored set is consistent should you point Exchange at it or move the files into place.
The files were moved without moving the configuration
You have this one if Somebody copied the database or logs to a new volume and edited properties, or changed a path by hand.
- Put the files back where the database object says they are, then move them properly with
Move-DatabasePath -Identity DB01 -EdbFilePath <new path> -LogFolderPath <new path>. - Remove every database copy first. Microsoft states this cmdlet cannot be run against replicated mailbox databases; you remove the copies, move, then add them back.
- Plan for downtime. Microsoft documents that a mounted database is automatically dismounted, moved and remounted, and is unavailable to users while dismounted.
The file is locked, or the storage under it is failing
You have this one if You get -1032 or -1022 rather than a mismatch complaint.
- Stop the Information Store service and any backup agent, then retry the operation.
- Run
vssadmin list writersand look for a writer left in a failed or waiting state by an abandoned backup. A reboot clears most of these. - For -1022, read the System log for storage timeout and reset entries and treat it as a hardware fault until the storage team proves otherwise.
- Confirm the antivirus exclusions cover the database, log and checkpoint paths so the scanner is not holding a handle.
Full reference
Matching the code to the layer
| Code | Symbolic name | Microsoft’s description |
|---|---|---|
-1216 |
JET_errAttachedDatabaseMismatch | An outstanding database attachment has been detected at the start or end of the recovery, but the database is missing or does not match attachment info |
-1811 |
JET_errFileNotFound | The file was not found |
-1022 |
JET_errDiskIO | There is a disk IO error |
-1032 |
JET_errFileAccessDenied | The file cannot be accessed because the file is locked or in use |
-1213 |
JET_errPageSizeMismatch | The database page size does not match the engine |
Reading them this way keeps you on the right track: -1216 is a filing problem, -1811 is a path problem, -1032 is a locking problem and -1022 is a storage problem. Only one of the four has anything to do with the contents of the database, and it is not -1216.
Moving a database properly
- Remove every copy of the database. Move-DatabasePath cannot run against a replicated database.
- Run Move-DatabasePath with the new EdbFilePath, the new LogFolderPath, or both. It relocates the files and changes the configuration together.
- Expect the database to be dismounted and remounted automatically, and unavailable to users in between.
- Add the copies back afterwards and let them seed.
- On Exchange 2016 and later the cmdlet can be run from anywhere; on 2013 and earlier it had to be run on the affected server unless ConfigurationOnly was used.
Copying files and editing paths in the directory does the second half of that job without the first, which is exactly how a log stream ends up describing a database that is no longer where the logs think it is.
Tools worth knowing
| Command | What it does |
|---|---|
Get-MailboxDatabase <name> | Format-List EdbFilePath,LogFolderPath |
What Exchange believes the paths are |
Move-DatabasePath |
The supported way to relocate a database or its logs |
vssadmin list writers |
Finds shadow copy writers stuck from a failed backup |
Get-MailboxDatabaseCopyStatus |
Whether a healthy copy exists that would make all of this unnecessary |
Microsoft no longer publishes a current reference for the Exchange database utility, so this article does not present its switch syntax as documented. Where you need to inspect a header or walk a log stream, run the tool without arguments to see the mode list for your build, and work against the copy you took.
Why this appears after a virtual machine restore
A snapshot of a running Exchange server captures the database and the logs at slightly different moments, and restoring one puts the files back in a state the engine never wrote. Use an Exchange-aware backup for anything you intend to restore. If a hypervisor snapshot is your only rollback position, take it with the services stopped and understand that restoring it is a rebuild path rather than an undo button.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
-1216 |
JET_errAttachedDatabaseMismatch: an outstanding database attachment was detected at the start or end of recovery, but the database is missing or does not match the attachment information | Microsoft Learn |
-1811 |
JET_errFileNotFound: the file was not found. A path problem rather than a damage problem | Microsoft Learn |
-1022 |
JET_errDiskIO: there is a disk IO error | Microsoft Learn |
-1032 |
JET_errFileAccessDenied: the file cannot be accessed because it is locked or in use | Microsoft Learn |
Confirm the fix worked
- The database and its logs are in the paths
Get-MailboxDatabasereports, and no other database writes into that log folder. - Recovery completes and the database header reads clean shutdown.
- The database mounts and
Get-MailboxDatabase -Statusshows it mounted. - Where copies were removed for a path move, they have been added back and have finished seeding.
Questions people ask about this
Does this cost anything to fix?
No. Every tool involved ships with Exchange and Windows. This is a filing problem, not a licensing one, and no product will sort out a log folder with two streams in it.
Can I delete the logs and mount the database anyway?
Only if the header says clean shutdown, in which case it needs none of them. If it says dirty shutdown, deleting the logs guarantees data loss and forces a restore.
Why will Move-DatabasePath not run?
Because the database is replicated. Microsoft documents that the cmdlet cannot be run against replicated mailbox databases: remove every copy first, move the path, then add the copies back.
Will the move take the database offline?
Yes. Microsoft documents that a mounted database is dismounted, moved and remounted automatically, and is unavailable to users while it is dismounted. Schedule it accordingly.
Is -1216 a sign of corruption?
Not usually. It is the engine protecting a healthy database from a log stream that does not belong to it. Once the right files are in the right place, recovery normally completes with nothing lost.
