03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

download 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

of 7

Transcript of 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    1/7

    Menu

    @mike_pfeiffer

    Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1

    by Mike Pfeiffer on July 9, 2011

    In this post I am going to outline this process of restoring mailbox data from a recovery database in Exchange 2010 SP1. This is kind of a long overdue follow up to my previous post on backing up

    Exchange 2010 using Windows Server Backup (WSB), which you can find right over here. What I am going to do here is restore an old database backup that was created using the steps in that post.

    Then Ill show you how to mount it as a recovery database, and then well t ake a look at several methods used to restore mail box data from it using t he Exchange Management Shell.

    So heres the scenario; Ive got a mailbox server called MBX1 with the following disk l ayout:

    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. I am doing regular backups using WSB and st oring them on the F:\ drive. I

    basically need to do a point i n time restore and retrieve some data from about s even months ago. Even though I have more recent backups, t hey dont have the data I need. I am goi ng to create a

    Recovery database from a previous backup so I can selectively restore mailbox data from it into the production database.

    Restoring the Backup

    The first thing Ill do is start WSB on the MBX1 server and select Recoverfrom the Actionmenu:

    As I mentioned earlier, the backups are stored on the F:\ drive on MBX1. On theGetting Startedscreen Ill select This server (MBX1)to specify the location of the backups and then Ill clickNext:

    I need to go back to t he end of last year to retrieve t he data Im interested in. You can see that on theSelect Backup Datescreen that the oldest successful backup I have within this time frame is from

    December 9th of 2010. Ill select that date and clickNext:

    On the Select Recovery Typescreen Ill select Applicationsand then click Next:

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    2/7

    On the Select Applicationscreen Ill select Exchange for the application to recover, then Ill clickNext:

    On the Specify Recovery Optionsscreen, I want to leave my existing database alone and restore the backup to an alternate location. Then I can create a Recovery Database later using these files and

    restore only specific mailbox data from the backup. I am going to set the restore location to E:\RecoveryDB since I know t he E:\ drive has plenty of space. After that, Ill clickNext:

    At this point I am ready to restore the data, so on theConfirmationscreen Ill hit the Recoverbutton and the restore will begin immediately:

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    3/7

    I can monitor the status of the restore on the Recovery Progressscreen. As long as the status comes back as CompletedI am in good shape:

    As you can see from the above screen shot, the restore was successful, so I can clickClose. I can navigate out to the E:\ drive to view the files:

    Everything looks good so far, I ju st need to make a note of a couple t hings before I move on. Notice t he 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 ori ginally stored on the E:\

    drive. I need to remember the path and the log generation prefix for the database, which ise01, as shown above. These details will be i mportant 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. Ill use the eseutil tool to play any outstandi ng transactions into the database to get it clean. Before I begin, Ill 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 DB01.edb

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

    What I will do next is perform a soft recovery to get the database consistent. Ill run the following command to do this:

    eseutil /r e01 /d

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    4/7

    The/rspecifies that Im doing a soft recovery. Thee01is the log generation prefix for the database. Im using the/dswitch without any arguments to specify the database path, which is in the current

    directory. Since the logs are also located here, I dont need to use the/lswitch, as it defaults to the current path. Once the operation has completed successfully, I can runeseutilagain with the/mhswitch

    to verify the database is clean shutdown:

    Now that my database has been restored and brought t o a clean shutdown state I can create the Recovery Database.

    Creating the Recovery Database

    The next step in the process is t o create the Recovery database using the database files restored from the backup. To do this, I ll use theNew-MailboxDatabasecmdlet with the following syntax:

    New-MailboxDatabase -Name RecoveryDB -EdbFilePath E:\RecoveryDB\E_\DB01\DB01.edb -LogFolderPath E:\RecoveryDB\E_\DB01 -Recovery -Server mbx1

    Notice that Ive specified the path to the database and log files using t he location where the database was restored. Also, the key t o creating the Recovery database is to make sure you use the-Recovery

    switch parameter, as shown above. You can see I got a warning message after running the command stating the Recovery database was created using an existing f ile, and that I need to ensure that the

    database is in a clean shut down state before I try to mount it. I already did this in the previous step, so I can safely i gnore this message and mount the database using the following command:

    Mount-Database RecoveryDB

    The Recovery database is now mounted, and Im ready to restore mailbox data.

    Finding Mailboxes and Performing a Simple Mailbox Restore

    Now that my Recovery database is online, I need to be able to see what mailboxes are available for restores. I can use theGet-MailboxStatisticscmdlet to do this:

    Get-MailboxStatistics -Database RecoveryDB

    If youre looking for a specific mailbox, you can filter the results using the following syntax:

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

    You can see in this command Ive used the ?alias for the Where-Objectcmdlet. Im using the -likeoperator to filter the results and only show me the mailboxes that start withMike.

    When restoring mailbox data from a Recovery database in Exchange 2010 SP1, we use theNew-MailboxRestoreRequestcmdlet. When running this cmdlet, t he source mailbox in the recovery database

    needs to be identified using one of three possible values; theDisplayName, MailboxGUID, or LegacyExchangeDNvalues. Keep in mind that you cannot reference the source mailbox using the

    Exchange Alias when performing a restore.

    So, lets take a look at the restore process. Based on the previous commands I 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 Ill use the following command:

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox 'Mike Pfeiffer' -TargetMailbox mpfeiffer

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

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    5/7

    Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics

    Dealing with Multiple Mailboxes with the same DisplayName

    Its possible that a Recovery database will have multiple mailboxes wit h the same display name. This can happen if there were one or more disconnected versions of a mailbox, in additi on to an active

    mailbox, in the same database during the ti me of the back up. In thi s case, you can use theMailboxGuidvalue to identify the source mailbox when doing a restore. Consider the following:

    Get-MailboxStatistics -Database RecoveryDB | ?{$_.DisplayName -like 'Isabel*'} | fl DisplayName,MailboxGuid,DisconnectDate

    Here you can see that there are two mailboxes with the same display name in the Recovery database. One has aDisconnectDatedefined, 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 s cenario where there are multiple mailboxes in a database with the same display name, use the above

    command to determine the MailboxGuidof each mailbox. You can then use this value to identi fy the correct mailbox when performing a restore.

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox 4a1d2118-b8cc-456c-9fd9-cd9af1f549d0 -TargetMailbox ihill

    Restoring Individual Mailbox Folders

    Here you can see that I am using the -IncludeFoldersparameter to specify that only data from the Inbox should be resto red from the mailbox in the recovery database:

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox administrator -TargetMailbox administrator -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 usi ng 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-MailboxRestoreRequestcmdlet. If you simply want to restore a single root folder, check out the-SourceRootFolderparameter.

    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 r estore command. Heres the command and output:

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox 'Mike Pfeiffer' -TargetMailbox mpfeiffer -TargetIsArchive

    Obviously, youll need to ensure that the t arget 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 t arget mailbox

    corresponds to the LegacyExchangeDN on the source mailbox. This ensures that you do not accidentially restore mailbox data t o the wrong location. If you need to restore data to an alternate mailbox,

    you can use the -AllowLegacyDNMismatchswitch parameter:

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox 'Mike Pfeiffer' -TargetMailbox administrator -TargetRootFolder Restore -AllowLegacyDNMismatch

    In this example, I am restoring the data from my mailbox in the recovery database to a sub-folder of the administrator mailbox calledRestore. Heres a screen shot of the administrator mailbox after

    running the above restore command:

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    6/7

    Be careful when restoring to alternate mailboxes. If you omit the-TargetRootFolder parameter, the data will be restored and merged into the existi ng 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

    You might find yourself in a situation where you need to restore data from all mailboxes in a recovery database. For example, lets say you need to restore the Contacts folder for all of your mailboxes. In

    this case, you could use a foreach loop to iterate through each mailbox in the recovery database and restore that particular folder to the active mailboxes:

    foreach($mailbox in Get-MailboxStatistics -Database RecoveryDB) {

    New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox $mailbox.DisplayName -TargetMailbox $mailbox.DisplayName -SourceRootFolder Contacts

    }

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

    Get-MailboxRestoreRequest -Status Queued

    As youve seen, there are a lot of steps and multiple options when it comes to restoring data from a recovery database. Obviously, this is not something you want to l earn on the fly when a disaster

    strikes. Id highly recommend documenting and testing your restore procedure on a regular basis.

    Related Posts

    Windows Server Backup with Volumes that Include Active and Passive Exchange Databases(1)

    Performing Maintenance on DAG Members in Exchange 2010 SP1(13)

    Administrator Audit Log Reports in HTML Format Exchange 2010 SP1(67)

    Backing Up Exchange 2010 using Windows Server Backup(2)

    Error: Couldnt find the Enterprise Organization Container when Creating a New Mailbox Export Request(11)

    58 comments add one

    Previous Comments

    Gurwinder Singh July 21, 2014, 7:22 am

    Great stuff..

    ReplyLink

    Dennis Aston July 25, 2014, 8:00 am

    Excellent stuff sir. THank you very much for taking the time to write this up , especially all of the different opti ons for recovery, ie -TargetRootFolder. Used that and its really nice. Thanks!

    ReplyLink

    Previous Comments

    Leave a Comment

    Name *

    Email *

    Website

    Comment

    Next post: Testing Exchange Autodiscover with PowerShell and the EWS Managed API

    Previous post: Microsoft MVP Award for 2011

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...

    7 12/08/2014 05:40 p.m.

  • 7/26/2019 03 Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1.pdf

    7/7

    Microsoft Exchange 2010

    PowerShell Cookbook

    Amazon| Packt

    Microsoft Exchange Server 2013 PowerShell

    Cookbook: 2nd Edition

    Amazon| Packt

    Search

    Recent Posts

    Im Delivering a PowerShell Workshop at Exchange Connections 2013

    Im Speaking at TechMentor 2013 in Las Vegas about Exchange Upgrades, Coexistence, and Hybrid Deployments

    Quick Tip: View or Export Lync Response Group Agents via PowerShell

    How To Add a Custom Holiday to an Exchange Calendar with PowerShell and the EWS Managed API

    Restricting Access to Lync for Disabled Active Directory Users

    Books

    toring Mailbox Data from a Recovery Database in Exchange 2010 SP1 http://www.mikepfeiffer.net/2011/07/restoring-mailbox-data-from-a-re...