Using EXMERGE to schedule “Brick Level Backups” based on AD OU…

A little while ago a third party company that provide professional services to us came to me asking some advice on how they could perform “brick level backups” of mailboxes without any specialist software for a group of specific users in Active Directory (its kind of a two way scratchy back relationship). I had a think about this and I came up with the following which makes use of EXMERGE, a custom script, a few scheduled tasks and organising your users in Organizational Units in AD.

About EXMERGE:

The Mailbox Merge Program is used to extract data from mailboxes on a Microsoft Exchange Server and then merge this data into mailboxes on either the same Microsoft Exchange Server or another destination. The program copies data from the source server or mailboxes into Personal Folders and then merges the data, in the Personal Folders, into mailboxes on the destination server. The program can also replace existing data instead of merging new data if specified by the Administrator.

One great thing about EXMERGE is that it can be scripted from a command line and by modifying a few settings in its .INI file and providing a source mailbox names file. I designed this method to work for both Exchange 2000 and 2003 therefore according the version of Exchange you are using you will need the correct version of EXMERGE which are as follows:

- Exchange 2000 (v6.0.4400)
-
Exchange Server 2003 (v6.5.7529) (345 kb)

Make sure that you have the correct rights to use EXMERGE by ensuring that you have applied the permissions correctly to your Exchange server (the account that Exmerge is to run under will require both “Send As” and “Recieve As” rights granted at the store level) otherwise your brick level backups will fail. Also ensure that you place EXMERGE in the BIN directory of the Exchange binaries otherwise you run the risk of the process failing due to EXMERGE not being able to find Exchange memory allocation DLL’s on the Windows Search path.

Using the Script:

First things first - generating the input names file. In this demo we want to perform a brick level back based upon the OU structure (so we can pick and choose whom had their mailboxes backed up in this fashion - great when you require an additional level of backup for VIP’s) so I designed a script that could be scheduled to generate an input file which could be used by EXMERGE to export the mailboxes in the given OU.
In essence the script exports the legacyExchangeDN value of each mailbox in the OU to a text file using the following command syntax:

cscript.exe xmerge.vbs ou=,ou=

Therefore an example command line would be:

cscript.exe xmerge.vbs ou=VIP_Users,ou=Head_Office c:\xMerge\users.txt

The following is the source code for the xmerge.vbs file: 

Dim objFileSystem,objOutputFile,StrDomain
Dim StrOu,objConn,objRecordSet

‘ Here we get the OU from the first parameter passed to the script

StrOU = WScript.Arguments.item(0)

‘Establish the domain Bind information

Set objRootDSE = GetObject(”LDAP://rootDSE”)
strADsPath = “LDAP://” & strOU & “,” &

objRootDSE.Get(”defaultNamingContext”)

Set objDomain = GetObject(strADsPath)

‘ From the second parameter passed to the script we get the legacy Exchange DN filename

objOutputFile = WScript.Arguments.item(1)

 

Set objFileSystem = CreateObject(”Scripting.fileSystemObject”)

Set objOutputFile = objFileSystem.CreateTextFile(objOutputFile, TRUE)

‘ Configure an ADODB connection to the directory

Set objCommand = CreateObject(”ADODB.Command”)
Set objConn = CreateObject(”ADODB.Connection”)

objConn.Open “Provider=ADsDSOObject;”

Set objCommand.ActiveConnection = objConn

‘ The following is the command statement that will return our Legacy Exchaneg DN to the text file.

objCommand.CommandText = “SELECT legacyExchangeDN FROM “+”‘”+strADsPath+”‘”+” WHERE objectClass = ‘user’”

objCommand.Properties(”searchscope”) = 2
objCommand.Properties(”Page Size”) = 1000

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF

objOutputFile.Write(objRecordSet.Fields(”legacyExchangeDN”) & vbCrLf)
objRecordSet.MoveNext

Wend

objOutputFile.Close

Set objFileSystem = Nothing

objConn.Close

What I recommend is that the above script should be configured to to run as part of a Windows batch file which can be scheduled to run at a given time (typically when mail flow is low on the system - say for example maybe 23:00) via the Window task scheduler.

Therefore a simple batch file to run the script command can be created containing the following command line:

cscript.exe xmerge.vbs ou=VIP_Users,ou=Head_Office c:\xMerge\users.txt

Configuring EXMERGE:

 

Now you can configure EXMERGE from its GUI interface, however I have found that it is just as easy to configure EXMERGE from its .ini file (which is entitled EXMERGE.ini) for tasks such as this.
The file itself is split into many different section however below are the areas of the file that we are interested in:

MergeAction

Should be set to the default (which is MergeAction=0) this means that EXMERGE is looking to export only.

SourceServerName

This value needs to the set to the name of the Exchange server that we are going to extracting data from - for example SourceServerName=MyServer

DataDirectoryName

The is the directory where you wish for the PST files to be placed - be mindful that the location needs to have enough space to accomodate the exported files.

FileContainingListOfMailboxes

The FileContainingListOfMailboxes value should correspond to the path that you set via the xMerge.vbs script for the users to process - therefore if you located this file in c:\xMerge\users.txt this is the value you should use here.

Making sure that the above configuration is correct you are now in a position to schedule the Export task. Create a batch file (which can be located in the same directory as the xMerge.vbs script and add the following command lines to the batch file entitled PxMerge.bat:

C:
CD c:\program files\exchsrvr\bin\
EXMERGE -F EXMERGE.INI -B

Obviously if your paths to the Exchange directory or the location of EXMERGE are different you will need to change them accordingly. Now all you need to do is schedule this task (using the Windows task scheduler) to run at a desired point. I would recommend that you schedule the PsMerge.bat task to run about 10 minutes after the xMerge.bat task that we created previously.

That’s it! - obviously keep an eye on disk space being used by the PST files and also ensure that the location is as secure as possible as PST files are inherently insecure. Another point of note is that if EXMERGE exports a mailbox to a PST that already exists you will find that EXMERGE inserts changes to the PST rather than recreating the file.



Add this page to your favorite Social Bookmarking websites
 
English (United Kingdom)