Exchange 2007 backups to PST

As many system administrators face the same issues with ExMerge falling away I went and dug up some method of still being able to make PST based backups of every user in an AD environment.

Requirements for this are: A 32-bit server / workstation with Outlook 2003 SP2 (I use Outlook 2007) or higher installed as well as the Microsoft Exchange Server 2007 Management Tools (32-Bit)

I used a bunch of other posts from around the web to come up with this solution but I’ll be merely posting my end-result.

Step 1

Most problems with the Export-Mailbox command in the Exchange Management Shell will be due to permissions problems. Create a new account that will run the script or use whatever backup / admin account you already have in place.

Using the Exchange Management Shell run: Get-Mailbox -OrganizationalUnit Employees | Add-MailBoxPermission -user “Domain\BackupUser” -AccessRights “FullAccess” this will grant the Backup-user the required permissions to perform the export. Note that you can ofcourse modify Get-Mailbox in any way you please to get the proper range of users. I just stuck with all the Employees for now.

Step 2

Now we are ready to export the users. Ofcourse I wanted this to be done in a batched job since I want this stuff to be done nightly every day with 7 days of retention.

echo Started Backup %date% %time% >> C:\batches\ExchangeLog.txt

CD “\Program Files\Microsoft\Exchange Server\Bin”
powershell -psconsolefile exshell.psc1 -command “Get-Mailbox -OrganizationalUnit Employees | Export-Mailbox -PSTFolderPath E:\ExTemp -Confirm:$false”

CD “\Program Files\Database Backup\”
BackupApp.exe backupExchangetoProdFile1.xml

cd \ExTemp
del *.* /S /Q

echo Finished Backup %date% %time% >> C:\batches\ExchangeLog.txt

Let me walk you through what I have done: The first thing I do is move to the proper directory (If you run this via Scheduled Task please also take this into account). Then powershell is loaded with the Exchange Management plugin and the command if given. Again the Get-Mailbox should be modified to suit you needs. I chose to export to a temp-dir (since in this scenario I’m moving the backups to a SAN for storage). Key option is -Confirm:False, otherwise it will prompt the user for input on the export command. After that is all done I use a custom program to zip & move the PSTs (In my experiance they zip nicely, about 50%)

Note: The machine that I used to create this script on was some old box I had standing about (P4 2.66 GHz with 1 GB RAM), performance was heavely impacted by the PST export command consuming 85~95% CPU usage. Make sure you test this method first before deploying it as it can lead to major system impact.

Leave a Reply

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