Restore Exchange Database

Restore the Exchange Database(s) and log files to a temp directory
For this example we will restore the Database mailbox.edb to C:\Recovery and the log files to C:\Recovery\Logs on the server ExchangeSVR

 

Get the database into a Clean Shutdown State

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


eseutil /mh mailbox.edb


Next is perform a soft recovery to get the database consistent. Run the following command to do this:


eseutil /r e01 /d /l “C:\Recovery\Logs”


The /r specifies a soft recovery.
The e01 is the log generation prefix for the database.
The /d switch without any arguments to specify the database path, which is in the current directory.
The /l switch specifies the log file directory, in this case the log directory below the database location.

Once the operation has completed successfully run eseutil again with the /mh switch to verify the database is clean shutdown:


eseutil /mh mailbox.edb

 

Create 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 use the New-MailboxDatabase cmdlet within the Exchange Management Shell with the following syntax:


New-MailboxDatabase -Name RecoveryDB -EdbFilePath C:\Recovery\mailbox.edb -LogFolderPath C:\Recovery\Logs -Recovery -Server ExchangeSVR


Now we must mount the Recovery Database using the following command within the Exchange Management Shell:


Mount-Database RecoveryDB

 

Finding Mailboxes and performing a Simple Mailbox Restore

Now that the Recovery Database is online, you will need to be able to see what mailboxes are available for restores. Use the Get-MailboxStatistics cmdlet to do this:


Get-MailboxStatistics -Database RecoveryDB


If you are looking for a specific mailbox you can filter the results with a command like this:


Get-MailboxStatistics -Database RecoveryDB | ?{$_.DisplayName -like 'User*'}


When restoring mailbox data from a Recovery database in Exchange 2010 SP1 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.

Note. Keep in mind that you cannot reference the source mailbox using the Exchange Alias when performing a restore.


To do a complete restore of the mailbox data to the original mailbox that is currently active in the production database use the following command:


New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox 'UserA' -TargetMailbox ‘UserA’


Depending on the size of the mailbox, it may take quite some time to perform the restore. You can keep tabs on the progress using the following command:


Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics

 

Restoring Individual Mailbox Folders

You can use the -IncludeFolders parameter to specify that only data from the Inbox should be restored from the mailbox in the recovery database:


New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox ‘UserA’ -TargetMailbox ‘UserA’ -IncludeFolders '#Inbox#'


The -IncludeFolders will accept a list of one or more mailbox folders. You 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 you wanted to restore only the contacts folder, 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 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 accidentally restore mailbox data to the wrong location. If you need to restore data to an alternate mailbox, you can use the -AllowLegacyDNMismatch switch parameter:


New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox ‘UserA’ -TargetMailbox ‘RestoreMailbox’ -TargetRootFolder UserA –AllowLegacyDNMismatch


In this example data will be restored from UserA’s mailbox in the recovery database to a sub-folder of the RestoreMailbox mailbox called UserA.