Pages

Wednesday, August 17, 2011

How Not to Restore Exchange 2007 Mailboxes

As an Exchange 2007 admin, it seems like I am breaking Exchange all the time. This time it was forgetting to move some users mailboxes before I dismounted and removed the storage group. Here's my story of the not-the-best-way to migrate Exchange 2007 mailboxes to new storage.  I would be moving the database and logs to a new storage array. I decided to create a new storage group and database and then move mailboxes. I could have taken the database offline and copied it to the new storage. If I had done that I would not have the privilege of writing this blog post. The mailboxes moves went very smoothly and after I was done I dismounted the storage group. At the end of the day, no one had called so I removed the storage group from Exchange and disconnected the iSCSI disk.

This is where things went terribly wrong. The next morning I realized I did not move the mailboxes of a few users from a child domain. I thought I might be okay since I still had the old database files. I reconnected the iSCSI disk and after a few attempts to mount the database it became obvious that I was going to have to pursue a different method. Of course, I could have just restored the mailboxes from tape but what is the fun in that? Besides I would have lost at least a days worth of mail that way too. I remember Recovery Storage Groups from Exchange 2003 so I thought that would be the way to go. RSG has changed quite a bit in Exchange 2007 but it was pretty easy to get the old database mounted by following the wizard.

This is when the second lightning bolt struck. Remember earlier when I said I removed the storage group? Well, that was a mistake too. Had I just left the storage group in place, I would not have the privilege of writing this blog post. Here's the scenario, I have about 15 Exchange users that still have attributes pointing to the deleted storage group. Simply creating a new storage group with the same name and mounting the old database did not work. The RSG option seems promising but the RSG wizard will only merge mailboxes if it can match attributes. Of course, I can not move messages to a mailbox that does not exist!

So here is the solution I came up with. I removed the mailboxes from the 15 users that did not have mailboxes. After waiting a few minutes to resolve any replication issues, I created new mailboxes for those users and verified that they now had empty mailboxes. For the next step, I switched to the Exchange Management Shell and entered this command all on one line.

Restore-Mailbox -Identity username -RSGDatabase "Recovery Storage Group\Mailbox Database" -RSGMailbox "Firstname Lastname" -TargetFolder "Restored-08152011"

This puts the contents of the old mailbox into a folder named Restored-08152011 in the new mailbox. I had to experiment a little to get the syntax right but this is what worked for me. For the -Identity switch I used the sAMAccountName or cn attribute. For the -RSGMailbox switch I used the display name attribute. You obviously need to substitute the name of your database for the -RSGDatabase switch. I probably could have worked a little more and scripted the whole thing, but I was more than happy to copy and paste this command a few times to get things going again.

The good news is this worked flawlessly. The folder contained all of the old mail. The only caveat is that I had to regenerate the Global Address List after this. I'm not sure why but I could not locate these new-old accounts until I did.

So the next time you bork Exchange, take comfort in knowing you are not alone.

1 comment:

  1. Nice post. But for readers who want to recover their mailboxes I would like to add that in order to restore an Exchange 2003 mailbox trust Stellar Phoenix Mailbox Exchange Server Recovery. The software is pretty easy to use and offers preview of user data in demo mode. More information is available at:
    http://exchange.stellarservertools.com/

    ReplyDelete