Exmerge Exchange 2007

I know it’s 2012 and I’m writing about a server from 2007. It’s still fairly relevant. Exchange 2010 has some different functionality, so keep that in mind. I also know that we don’t use exmerge in post-2003 exchange environments. But I like the terminology.

Basically I had a user delete all of their calendar items and they were not showing up in the recover deleted items section of outlook. Good thing I had a backup. Bad thing was the database their email was on grew to 81GB. Worse thing was the email server and the backup server were connected by a measly 20mbps pipe.

Fast forward 11 hours and I had a copy of my EDB file on my exchange server. So now what?

Create a folder called C:\exch_recovery (or anything you want, just be sure to change the directories in the following commands)
Open the Exchange PowerShell. PowerShell is required as a recovery database is not visible by general users. It helps if you’re an exchange/domain/enterprise admin in this case.

Create the storage group for recovery
New-StorageGroup -Server SERVERNAME -LogFolderPath c:\exch_recovery -SystemFolderPath C:\exch_recovery -Name rsg -Recovery

I’m assuming you’re trying to recover something from your original Mailbox Database, otherwise change the mailbox name as appropriate.
Copy your BACKUP edb into the C:\exch_recovery\ directory.

Make sure that the database is in “clean shutdown” mode.
eseutil /mh path/to/edb/file.edb

If not in a clean shutdown mode, and you have the log files required, run the following (assuming the log files start with E01):
eseutil /r "e01" /l C:\path\to\log\files\directory /d C:\path\to\edb\file\directory

Now tell Exchange about this database
New-MailboxDatabase -MailboxDatabaseToRecover "Mailbox Database" -StorageGroup SERVERNAME\rsg -EdbFilePath "C:\exch_recovery\Mailbox Database.edb"

Allow your database to be restored
Set-MailboxDatabase -Identity "SERVERNAME\rsg\Mailbox Database" -AllowFileRestore:$TRUE

As this database is still hidden, run the following to mount it
Mount-Database -Identity "SERVERNAME\rsg\mailbox database"

The restore-mailbox command will merge the mail from the recovery database into the current database automatically. If the user does not exist, there will obviously be no merge and only a copy will occur
Restore-Mailbox -Identity "JOHN SMITH" -RsgDatabase "SERVERNAME\rsg\mailbox database"

Optional Cleanup
Remove-MailboxDatabase -Identity "SERVERNAME\rsg\mailbox database"
Remove-Storagegroup -Identity "SERVERNAME\rsg"

Is this the best way? Probably not, but it worked for me. The user now has their calendar items again and lost NO MAIL.

Leave a Reply

Your email address will not be published. Required fields are marked *