Exchange 2010 SP1 – Restoring Mailbox Data from a Recovery Database

Exchange 2010 SP1 – Restoring Mailbox Data from a Recovery Database

Exchange-2010-Logo-BigWhile ago I’ve published an article, “How to Backup Exchange 2010 for Free” and I’ve got a lot of emails and comments where people were asking me to write an article about how to do a restore. So, let’s see how to do that Smile. What I am going to do here is restore an old database backup that was created using the steps in my previous post. We’ll see how to use a Recovery Database. We will take a look at several methods used to restore mailbox data from it using the Exchange Management Shell.

 

So here’s the scenario: Mailbox server called MBX1 with the following disk layout:

  • C:\ – System Drive
  • E:\ – Exchange Database
  • F:\ – Database backups

The MBX1 server has a single database called DB01 and the database file (along with the logs) are stored on the E:\ drive. We are doing regular backups using WSB and storing them on the F:\ drive. We basically need to do a point in time restore and retrieve some data from about seven months ago. So, we are going to create a Recovery Database from a previous backup so we can selectively restore mailbox data from it into the production database.

Restoring the Backup

The first thing we’ll do is start WSB on the MBX1 server and select Recover from the Action menu:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P1

In our case, the backups are stored on the F:\ drive on MBX1. On the Getting Started screen we have to select This server (MBX1) to specify the location of the backups and then I’ll click Next:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P2

Let’s go back to the end of last year to retrieve the data we are interested in. You can see that on the Select Backup Date screen that the oldest successful backup we have within this time frame is from December 9th of 2010. Let’s select that date and click Next:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P3

On the Select Recovery Type screen select Applications and then click Next:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P4

On the Select Application screen let’s select Exchange for the application to recover, then I’ll click Next:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P5

On the Specify Recovery Options screen, let’s restore the backup to an alternate location. Then we can create a Recovery Database later using these files and restore only specific mailbox data from the backup. We are going to set the restore location to E:\RecoveryDB. Now we can click Next:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P6

Now let’s hit the Recover button and the restore will begin immediately:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P7

We can monitor the status of the restore on the Recovery Progress screen. If we have a good backup Winking smile, we should get the status as Completed:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P8

If the restore was successful, so we can click Close. Navigate out to the E:\ drive to view the files:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P9

Let’s make a note of a couple things before we move on. Notice the directory structure in the above screen shot. The database was restored to a sub folder of the recovery location specified during the restore. It restored the database in a folder called DB01 (which was the original folder name) in a sub directory called E_ since it was originally stored on the E:\ drive. We need to remember the path and the log generation prefix for the database, which is e01, as shown above. These details will be important for getting the database into consistency in the next step.

Getting the Database into a Clean Shutdown State

In order for Exchange to mount a database, it needs to be in a clean shutdown state. We’ll use the eseutil tool to play any outstanding transactions into the database to get it clean. Let’s open a command prompt, switch to the directory that contains the database and logs, and use the following command to view the status:

<a href="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P10" border="0" alt="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P10" src="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P10_thumb.png" width="712" height="61"></a>

When reviewing the output, the database state will be reported as Dirty Shutdown:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P11

What we have to do next is perform a soft recovery to get the database consistent. We have to run the following command to do this:

<a href="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P12" border="0" alt="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P12" src="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P12_thumb.png" width="712" height="312"></a>

The /r specifies that we are doing a soft recovery. The e01 is the log generation prefix for the database. We are using the /d switch without any arguments to specify the database path, which is in the current directory. Since the logs are also located here, we don’t need to use the /l switch, as it defaults to the current path. Once the operation has completed successfully, we can run eseutil again with the /mh switch to verify the database is clean shutdown:

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P13

 

Creating the Recovery Database

The next step in the process is to create the Recovery database using the database files restored from the backup. To do this, we’ll use the New-MailboxDatabase cmdlet with the following syntax:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxDatabase </span><span style="color: #000000;">-</span><span style="color: #000000;">Name RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">EdbFilePath E:\RecoveryDB\E_\DB01\DB01.edb </span><span style="color: #000000;">-</span><span style="color: #000000;">LogFolderPath E:\RecoveryDB\E_\DB01 </span><span style="color: #000000;">-</span><span style="color: #000000;">Recovery </span><span style="color: #000000;">-</span><span style="color: #000000;">Server mbx1</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P14

Notice that we’ve specified the path to the database and log files using the location where the database was restored. Also, the key to creating the Recovery database is to make sure you use the -Recovery switch parameter, as shown above. You can see we got a warning message that we need to ensure that the database is in a clean shut down state before we try to mount it. We already did this in the previous step, so we can safely ignore this message and mount the database using the following command:

<a href="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P15.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P15" border="0" alt="Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P15" src="http://www.curu.ca/wp-content/uploads/Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P15_thumb.png" width="686" height="42"></a>

We’re ready to restore mailbox data Smile.

 

Finding Mailboxes and Performing a Simple Mailbox Restore

Now that our Recovery Database is online, we need to be able to see what mailboxes are available for restores. We can use the Get-MailboxStatistics cmdlet to do this:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxStatistics </span><span style="color: #000000;">-</span><span style="color: #000000;">Database RecoveryDB</span></div>

If we’re looking for a specific mailbox, we can filter the results using the following syntax:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxStatistics </span><span style="color: #000000;">-</span><span style="color: #000000;">Database RecoveryDB </span><span style="color: #000000;">|</span><span style="color: #000000;"> </span><span style="color: #000000;">?</span><span style="color: #000000;">{</span><span style="color: #800080;">$_</span><span style="color: #000000;">.DisplayName </span><span style="color: #008080;">-like</span><span style="color: #000000;"> 'Misha</span><span style="color: #000000;">*</span><span style="color: #000000;">'}</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P17

You can see in this command we’ve used the ? alias for the Where-Object cmdlet. We’re using the -like operator to filter the results and only show us the mailboxes that start with Misha.

When restoring mailbox data from a Recovery database in Exchange 2010 SP1, we use the New-MailboxRestoreRequest cmdlet. When running this cmdlet, the source mailbox in the recovery database needs to be identified using one of three possible values; the DisplayName, MailboxGUID, or LegacyExchangeDN values. Keep in mind that we cannot reference the source mailbox using the Exchange Alias when performing a restore.

So, let’s take a look at the restore process. Based on the previous commands we can see that there is a copy of my mailbox in the Recovery database. To do a complete restore of the mailbox data to the original mailbox that is currently active in the production database we’ll use the following command:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox 'Misha Hanin' </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetMailbox mhanin</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P18

Depending on the size of the mailbox, it may take quite some time to perform the restore. We can monitor the progress using the following one-liner:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">|</span><span style="color: #000000;"> Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequestStatistics</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P19

 

Dealing with Multiple Mailboxes with the same DisplayName

It’s possible that a Recovery database will have multiple mailboxes with the same display name. This can happen if there were one or more disconnected versions of a mailbox, in addition to an active mailbox, in the same database during the time of the back up. In this case, you can use the MailboxGuid value to identify the source mailbox when doing a restore. Consider the following:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxStatistics </span><span style="color: #000000;">-</span><span style="color: #000000;">Database RecoveryDB </span><span style="color: #000000;">|</span><span style="color: #000000;"> </span><span style="color: #000000;">?</span><span style="color: #000000;">{</span><span style="color: #800080;">$_</span><span style="color: #000000;">.DisplayName </span><span style="color: #008080;">-like</span><span style="color: #000000;"> 'Sean</span><span style="color: #000000;">*</span><span style="color: #000000;">'} </span><span style="color: #000000;">|</span><span style="color: #000000;"> fl DisplayName,MailboxGuid,DisconnectDate</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P20

Here we can see that there are two mailboxes with the same display name in the Recovery database. One has a DisconnectDate defined, meaning it is a disconnected mailbox, and the other one does not which means it was the active mailbox in the database at the time of the backup. If you run into a scenario where there are multiple mailboxes in a database with the same display name, use the above command to determine the MailboxGuid of each mailbox. You can then use this value to identify the correct mailbox when performing a restore.

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox 4a1d2118</span><span style="color: #000000;">-</span><span style="color: #000000;">b8cc</span><span style="color: #000000;">-</span><span style="color: #000000;">456c</span><span style="color: #000000;">-</span><span style="color: #000000;">9fd9</span><span style="color: #000000;">-</span><span style="color: #000000;">cd9af1f549d0 –TargetMailbox shanin</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P21

 

Restoring Individual Mailbox Folders

Here you can see that we are using the -IncludeFolders parameter to specify that only data from the Inbox should be restored from the mailbox in the recovery database:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox administrator </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetMailbox administrator </span><span style="color: #000000;">-</span><span style="color: #000000;">IncludeFolders '</span><span style="color: #008000;">#</span><span style="color: #008000;">Inbox#'</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P22

The -IncludeFolders will accept a list of one or more mailbox folders. We can specify well-known folder names as well as personal folders using this parameter. Notice that the value needs to be enclosed in hash marks (#). For example, if we wanted to restore only the contacts folder, use need to use #Contacts#, or #Tasks# for the Tasks folder, and so on. For more details, check out the help for this parameter in the TechNet documentation for the New-MailboxRestoreRequest cmdlet. If you simply want to restore a single root folder, check out the -SourceRootFolder parameter.

 

Restoring to an Archive Mailbox

Restoring a mailbox to a users archive is as simple as tacking on the -TargetIsArchive switch parameter to our original restore command. Here’s the command and output:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox 'Misha Hanin' </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetMailbox mhanin </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetIsArchive</span></div>

Restoring-Mailbox-Data-from-a-Recovery-Database-in-Exchange-2010-SP1-P23

Keep in mind,  we need to ensure that the target mailbox has been archive enabled for this to work.

 

Restoring to an Alternate Mailbox

By default, the New-MailboxRestoreRequest cmdlet looks for a matching LegacyExchangeDN on the source and destination mailbox, or checks to see that an X500 proxy address on the target mailbox corresponds to the LegacyExchangeDN on the source mailbox. This ensures that you do not accidentially restore mailbox data to the wrong location. If you need to restore data to an alternate mailbox, you can use the -AllowLegacyDNMismatch switch parameter:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox 'Misha Hanin' </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetMailbox administrator </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetRootFolder Restore </span><span style="color: #000000;">-</span><span style="color: #000000;">AllowLegacyDNMismatch</span></div>

Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1-P24

In this example, we are restoring the data from my mailbox in the recovery database to a sub-folder of the administrator mailbox called Restore. Be careful when restoring to alternate mailboxes. If we omit the -TargetRootFolder parameter, the data will be restored and merged into the existing folders in the target mailbox. On the other hand, that might be exactly what you want — if so, just remove the -TargetRootFolder parameter.

 

Bulk Restores

We might find our self in a situation where we need to restore data from all mailboxes in a recovery database. For example, let’s say we need to restore the Contacts folder for all of our mailboxes. In this case, we could use a foreach loop to iterate through each mailbox in the recovery database and restore that particular folder to the active mailboxes:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
</span><span style="color: #0000FF;">foreach</span><span style="color: #000000;">(</span><span style="color: #800080;">$mailbox</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxStatistics </span><span style="color: #000000;">-</span><span style="color: #000000;">Database RecoveryDB) {
  New</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceDatabase RecoveryDB </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceStoreMailbox </span><span style="color: #800080;">$mailbox</span><span style="color: #000000;">.DisplayName </span><span style="color: #000000;">-</span><span style="color: #000000;">TargetMailbox </span><span style="color: #800080;">$mailbox</span><span style="color: #000000;">.DisplayName </span><span style="color: #000000;">-</span><span style="color: #000000;">SourceRootFolder Contacts
}
</span></div>

This might take a while, we can monitor the progress using the Get-MailboxRestoreRequest with the -Status parameter:

<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><span style="color: #000000;">
Get</span><span style="color: #000000;">-</span><span style="color: #000000;">MailboxRestoreRequest </span><span style="color: #000000;">-</span><span style="color: #000000;">Status Queued</span></div>

As we’ve seen, there are a lot of steps and multiple options when it comes to restoring data from a recovery database. It is highly recommended documenting and testing a restore procedure on a regular basis Smile!

About the Author

Misha Hanin

Hi, my name is Misha Hanin. I have served as an IT Network Administrator and IT Consultant for over 15 years. I have a number of certifications including CNE, Citrix CCA, VMWare VCP, MCP+I, MCSE, MCTS, MCITP Enterprise Messaging Administrator & MCITP Enterprise Administrator. Microsoft presented me with the 2008 Microsoft® MVP Award (MVP) in Windows Server - Admin Frameworks! 

Comments (7):

  1. Thank you.
    New editions are always good!

  2. Very useful and comprehensive info when it comes to restore the Exchange.
    Great job Misha!

  3. Hi Misha,

    This is very Useful….Hope doing great..

  4. Hi!
    Nice post, thx. Did you havea situation where the restore job would not start and stay “queued” all the time?

  5. No, i didn’t have that.

  6. Hi its a nice post to make a plan to recover and repair mailbox from corrupt and damage database but i have provide you a new idea for solve this issue with any time waste. Kernel for exchange server recovery software not recover mailbox only but solve also many more issue related exchanges database. For more details visit here : http://www.softwaredatarecovery.net/exchangerecovery.html

Leave a Reply



*