Important messages were deleted!!!
Our starting scenario is this: important emails were deleted from a mailbox that need to be recovered. Deleted messages are purged from the retention storage.
In this case, we copy the mailbox database that contains the mailbox from a backup, mount it and copy the missing messages from the backup into the live mailbox.
- Original mailbox: DB01
- EDB file location: C:\ExchangeDatabases\DB01\db\DB01.edb
- Log files location: C:\ExchangeDatabases\DB01\logs
1. Copy a mailbox database from your backup to the Exchange server.
Place the copied DB01 database from your backup in the following location:
- EDB file location: C:\ExchangeDatabases\DB01_BACKUP\db\DB01.edb
- Log files location: C:\ExchangeDatabases\DB01_BACKUP\logs
We leave the filename intact, although you can rename it. In that case, amend the rest of the script accordingly.
2. Check the backup DB for errors
Use the ESEUTIL app to check the database for errors, or clear the dirty shutdown state it's in, It is very likely if the backup was made during operation.
eseutil /r E00 /d C:\ExchangeDatabases\DB01_BACKUP\db\DB01.edb /l C:\ExchangeDatabases\DB01_BACKUP\logs
3. Create a recovery DB
We need to add the freshly copied backup database to the Exchange system. We use the following command to create a recovery database in Active Directory. It is necessary because this is how we'll be able to mount the database in the upcoming steps.
New-MailboxDatabase -Name "DB01_BACKUP" -Recovery -EdbFilePath C:\ExchangeDatabases\DB01_BACKUP\db\DB01.edb -LogFolderPath C:\ExchangeDatabases\DB01_BACKUP\logs -Server MB01
4. Restart the IS service
Restart-Service MsExchangeIS
5. Mount the recovery DB
Mount-Database "DB01_BACKUP"
6. Restore items in mailbox
The last step is the key step. We use the following commands which will initiate a restore session. During that process, the server will compare the backup version of the user mailbox with the live version and copy the messages that the live mailbox is missing.
$mailbox = (Get-Mailbox jdoe).ExchangeGuid # Whole mailbox New-MailboxRestoreRequest -Name "John Doe restore" -SourceDatabase "DB01_BACKUP" -SourceStoreMailbox $mailbox -TargetMailbox "jdoe" # Restore items only in the "Inbox" folder New-MailboxRestoreRequest -Name "John Doe restore" -SourceDatabase "DB01_BACKUP" -SourceStoreMailbox $mailbox -TargetMailbox "jdoe" -IncludeFolders "Inbox"
7. Remove the recovery DB
We are done. As an optional step we can remove and delete the backup database DB01_BACKUP as we don't need it anymore.
Remove-MailboxDatabase DB01_BACKUP
Comments