Oct 12 2010

Exchange 2003 Recovering one mailbox from server backup

These are the steps involved in recovering a mailbox from Microsoft Exchange server 2003 from a mailbox store folder or .edb  database file.  In the case that inspired this post, Entourage deleted about 90% of the user’s data including Calendar, Emails, Contacts, etc.  All I had to work with server side, was the backup of the entire exchange server, from the day before, which contained a non-consistent .edb.  The microsoft documentation pretty much explains the process but they are not clear on how to actually mount the backup .edb.  This is a modified version of the Microsoft Documentation, where I have added where I think it lacks clarity.

First you need to create (but not mount) the Recovery Group.  This is assuming that you already have the server up with an active Mailbox store so that your user(s) can continue receiving emails and working while you recover their old emails.

Create a Recovery Storage Group

To create a Recovery Storage Group:

  1. Start Exchange System Manager.
  2. Expand Administrative Groups (if appropriate), expand AdministrativeGroupName(if appropriate), and then expand Servers.
  3. Right-click ServerName, point to New, and then click Recovery Storage Group.
  4. In the Name box, type a name for the Recovery Storage Group (You can call it “Recovery Storage Group”).
  5. In the Transaction log location and in the System path location boxes, specify a location for the transaction log files and for the system path. Make sure that the location that you specify for the transaction log files for the Recovery Storage Group is different from the location that is specified for the transaction log for the original storage group.  From now on, we’ll refer to this location as the “recovery folder”.
  6. Click OK.
  7. Right-click the Recovery Storage Group that you created, and then click Add Database to Server
  8. In the Select database to recover dialog box, click the mailbox store that you want to add to the Recovery Storage Group, and then click OK.
  9. In the Mailbox Store Properties dialog box, review the properties of the mailbox store, and then click OK.

OK at this point you have already created your Recovery Storage Group, and you the new database file should also be created.  If you browse the folder where you specified earlier (the “recovery folder”), you will find a new .edb was created.  In the exchange manager, you may notice the arrow pointing down, specifying that the database has not been mounted yet.

Next, you will have to extract the .edb, and all related transaction log files (it’s usually safest to copy the entire mailbox store directory) from your backup into a temporary folder, this could be the root, the desktop etc.  Once there, let’s run some commands against it to make sure it’s safe to work with.

Manually Copy Database Files to a Recovery Storage Group

  1. Verify that the database that you want to restore is consistent and that it is in a “clean shutdown” state. To do so, open a command prompt, switch to the ExchSrvr\Bin folder, type the following line, and then press ENTER:
    Eseutil /mh YourDatabaseName.edb  (replace YourDatabaseName with the full path of your .edb that was recovered from backup)
    In the output that appears in the Command Prompt window, note whether the State line shows as State: Clean Shutdown or State: Dirty Shutdown.
  2. Do one of the following, as appropriate to your situation:
    If the database is consistent (if it says Clean Shutdown), go to step 3.
    If the database is not consistent (Dirty Shutdown) and if the database log files exist, use the Eseutil.exe tool to perform a soft recovery on the database. When you perform a soft recovery, uncommitted logs are committed to the database. To perform a soft recovery, switch to the ExchSrvr\Bin folder at a command prompt, type the following line, where rnn is the log file prefix and database_folder_path is the name of the folder where the database file is located, and then press ENTER:

    Eseutil /r rnn /i /ddatabase_folder_path

    For example, you might type the following:
    eseutil /r r00 /i /d”c:\Bakcup\Echsrvr\Storage Group”

    Note There is no space after the /d switch.

    If the database is not consistent and if the database log files do not exist, use the Eseutil.exe tool to perform a hard repair on the database.

    When you use the following command, Exchange Server data loss occurs. Data loss can be significant; however, in most situations the data loss is minimal. The following command is a hard or forcible state recovery command. Use it only if the database still does not return to a consistent state after you run the Eseutil /mh YourDatabaseName.edb command.

    To perform a hard repair, open a command prompt, switch to the ExchSrvr\Bin folder, type the following line, and then press ENTER:

    eseutil /p
    YourDatabaseName.edb Be patient, this could take a long time depending on the size of the .edb.

  3. Immediately after the successful completion of the hard repair, perform an offline defragmentation of the repaired database. To perform an offline defragmentation, open a command prompt, switch to the ExchSrvr\Bin folder, type the following line, and then press ENTER:eseutil /d YourDatabaseName.edb This usually takes hours. If you have constraint, it’s not recommended by Microsoft, but you can technically cancel it and continue.

  4. Copy the .edb and the .stm database files that you have been working on (the ones in that temporary folder) to the the appropriate folders that you specified earlier when you created the Recovery Storage Group (remember the “recovery folder”).
  5. Take note of the name of the .edb and ,stm files (created earlier in the first section).  Delete the .edb and .stm files that you created, and rename the ones that were brought from backup to have the same exact name.  This way, when exchange tries to mount the recovery store, it will mount the database brought back from backup.
  6. Go into the System Manager, right click the database in the recovery storage group, and click Mount.
  7. After a progress indicator, it should have successfully mounted the mailbox store.
  8. To recover the single mailbox, find it in Mailboxes (still under the Recovery Store), Right-click, and select Recover Mailbox.  Make sure you specify merge in the wizard, this will leave all new emails intact and merge the old ones with the new.

If this helps 1 person out there it was worth it.  Feel free to contact me with any suggestions, errors, etc.

Resource: http://support.microsoft.com/kb/824126/