In recent articles we’ve looked at how to backup an Exchange 2013 mailbox server, how to restore databases to an Exchange 2013 mailbox server, and how to create a recovery database in Exchange 2013.
In this article I will demonstrate how to use the recovery database to restore data to a mailbox.
Obviously the first step in this process is to restore the database that has the data you’re interested in into a recovery database. You can find the steps for performing that task using Windows Server Backup here.
Here is my recovery database ready to go.
[PS] C:\>Get-MailboxDatabase | where recovery Name Server Recovery ReplicationType ---- ------ -------- --------------- RecoveryDB E15MB1 True None
The mailbox I need to restore is Alan Reid, and I can verify that the mailbox is available in the recovery database by using Get-MailboxStatistics.
[PS] C:\>Get-MailboxStatistics -Database RecoveryDB | where displayname -eq "Alan Reid" DisplayName ItemCount StorageLimitStatus ----------- --------- ------------------ Alan Reid 16971
Restoring from a recovery database involves creating a mailbox restore request, using the New-MailboxRestoreRequest cmdlet.
New-MailboxRestoreRequest requires you to specify:
- A source database (in this case, the recovery database)
- A source mailbox
- A target mailbox
The source and target don’t necessarily need to be the same, and there are a variety of other parameters available to handle situations such as including/excluding specific mailbox folders, handling corrupt items, conflict resolution, and so on.
Let’s take a look at some recovery scenarios to demonstrate how you can use mailbox restore request.
Scenario – Restoring Sent Items Folder
In this scenario Alan Reid has lost all of this sent items older than 3 weeks, and for the sake of demonstration let’s also assume they can’t be restored from the recoverable items folder.
At the moment he has 869 items in his sent items folder.
[PS] C:\>Get-MailboxFolderStatistics alan.reid -FolderScope SentItems | fl name,items* Name : Sent Items ItemsInFolder : 869 ItemsInFolderAndSubfolders : 869
To restore the sent items folder from the recovery database we create a mailbox restore request.
[PS] C:\>New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox "Alan Reid" -TargetMailbox Alan.Reid - IncludeFolders "#SentItems#" Name TargetMailbox Status ---- ------------- ------ MailboxRestore exchange2013demo.com/Company/People/Sydney/... Queued
Monitoring the Mailbox Restore Request
Notice that the mailbox restore request is created initially with a status of “Queued”. We can monitor the progress of the restore request using Get-MailboxRestoreRequest and Get-MailboxRestoreRequestStatistics.
[PS] C:\>Get-MailboxRestoreRequest Name TargetMailbox Status ---- ------------- ------ MailboxRestore exchange2013demo.com/Company/People/Sydney/... InProgress [PS] C:\>Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics Name StatusDetail TargetAlias PercentComplete ---- ------------ ----------- --------------- MailboxRestore CopyingMessages alan.reid 50
While the restore is in progress you might be interested to know the percent completed, and the numbers of items transferred so far compared to how many are estimated to be transferred in total.
[PS] C:\>Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics | fl percentcomplete,itemstransferred,*count* PercentComplete : 71 ItemsTransferred : 4765 BadItemsEncountered : 0 LargeItemsEncountered : 0 EstimatedTransferItemCount : 7866
When the restore has finished the status will change to “Completed”.
[PS] C:\>Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics Name StatusDetail TargetAlias PercentComplete ---- ------------ ----------- --------------- MailboxRestore Completed alan.reid 100
After the restore Alan Reid’s sent items folder has a much larger item count.
[PS] C:\>Get-MailboxFolderStatistics alan.reid -FolderScope SentItems | fl name,items* Name : Sent Items ItemsInFolder : 8120 ItemsInFolderAndSubfolders : 8120
Note: The default behaviour for conflict resolution is to keep the source item (ie the item being restored from the recovery database). You can use the -ConflictResolutionOption parameter to specify KeepLatestItem or KeepAll instead if you wish.
Scenario – Restoring Entire Mailbox
In this example a staff member has left the organization some months or years ago, then been re-hired, and wants their old emails, contacts, and calendar items back. Because the mailbox was deleted when they left the organization their new mailbox is empty on arrival.
[PS] C:\>Get-MailboxStatistics "ann parker" DisplayName ItemCount ----------- --------- Ann Parker 0
A recovery database is created from a backup taken while the original mailbox still existed.
[PS] C:\>Get-MailboxStatistics -Database RecoveryDB | where displayname -eq "ann parker" DisplayName ItemCount ----------- --------- Ann Parker 6107
A new mailbox restore request is used to restore the entire mailbox contents from the recovery database. Because the LegacyExchangeDN is different for the new mailbox an additional -AllowLegacyDNMisMatch parameter is required to allow the restore to occur. This would be the same situation if you were trying to restore a person’s mailbox data into a complete different person’s mailbox.
[PS] C:\>New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox "Ann Parker" -TargetMailbox Ann.Parker -AllowLegacyDNMismatch
When the restore is complete Ann Parker’s mailbox has the recovered items in it.
[PS] C:\>Get-MailboxStatistics "ann parker" DisplayName ItemCount Stor ----------- --------- ---- Ann Parker 6103
Scenario – Restoring to a Different Folder
In this example David Abbott knows he has lost some emails but isn’t sure exactly what or when. He has asked that his Inbox be restored to a different folder so that he can look through it and recover any items he finds in there that he needs.
A new mailbox restore request is created using the -TargetRootFolder parameter to specify where to recover the items to, and including only the Inbox and any subfolders of the Inbox.
[PS] C:\>New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox "David Abbott" -TargetMailbox David.Abbott -TargetRootFolder "Restored Items" -IncludeFolders "#Inbox#/*"
David will be able to see the folder in Outlook or OWA almost as soon as the restore request begins processing.
Cleaning Up Mailbox Restore Requests
You may notice that completed mailbox restore requests are left in place and are not automatically removed. This is so you can do any analysis or reporting you need to do on them before they are removed.
[PS] C:\>Get-MailboxRestoreRequest -Status Completed Name TargetMailbox Status ---- ------------- ------ MailboxRestore1 exchange2013demo.com/Company/People/Melbour... Completed MailboxRestore exchange2013demo.com/Company/People/Sydney/... Completed MailboxRestore exchange2013demo.com/Company/People/Melbour... Completed MailboxRestore exchange2013demo.com/Company/People/Melbour... Completed
When you are happy to remove the completed mailbox restore requests you can use Remove-MailboxRestoreRequest.
[PS] C:\>Get-MailboxRestoreRequest -Status Completed | Remove-MailboxRestoreRequest
Summary
Restoring mailbox items from a recovery database involves the creation of mailbox restore requests. As you can see from the example scenarios above there are many different ways that the mailbox restore request can be configured to run to suit almost any situation that you encounter.
This article Restoring a Mailbox from an Exchange Server 2013 Recovery Database is © 2014 ExchangeServerPro.com
Get more Exchange Server tips at ExchangeServerPro.com