Backing up your PSTs with DataNow and Environment Manager

*This post originally appeared on the AppSense blog prior to the rebrand in January 2017, when AppSense, LANDESK, Shavlik, Wavelink, and HEAT Software merged under the new name Ivanti.

In this article I’m going to take a look at a solution to a common problem for IT admins all over the world; How do you back up locked files, such as Outlook PSTs, while they’re in use?

It came to my attention that some of our customers who were already using Environment Manager and DataNow were looking for a solution to this problem that didn’t involve specialist 3rd party backup software. The brief was to provide a mechanism using their existing software which would take a copy of the users’ PSTs from their local profiles and transfer them to a remote location in a way that wouldn’t inconvenience the user.

The Problem

To set the scene, when Outlook opens a PST file from its default location in:

  • %LocalAppData%\Microsoft\Outlook (Office 2007 and earlier)
  • %UserProfile%\Documents\Outlook Files (Office 2010 and later)

It locks the file so that other processes on the system can’t modify or copy it. This is a good thing because the delicate nature of PST files mean that they have to be cleanly closed by Outlook to ensure that the contents aren’t corrupted. If it was possible to copy a PST file while Outlook had it open, the resultant file may well be damaged and content could be lost.

The following screenshot shows that Outlook.exe has a handle open to my PST file. The screenshot is of SysInternals’ Process Explorer’s Handles view:


What this means is that the following error occurs when I attempt to copy the PST file from C:\Users\Manuel\AppData\Local\Microsoft\Outlook\MyStuff.pst to another location while Outlook is open.


It’s not as simple as it first appears

At this point, you may well be reading this and think “Why not just copy the PST files to a network share at user logon or logoff with Environment Manager?” This is obviously possible, but would significantly inconvenience the user as they’d have to wait while potentially several GB of files are copied before they could log on or off. In addition, this would only work if the user was connected to their corporate network at the time that the EM action kicked in.

I think that anyone who’s regularly on the road would shudder at the thought of having to wait for all of their PSTs to copy over Wi-Fi/VPN before they could log off and shut down their laptop.

Using Environment Manager, DataNow (and a clever script) to back up the files

To produce a solution to this problem, there are three functional elements that need to be considered to ensure that the solution is both administratively simple, and non-intrusive for end-users:

  1. PST Files must be backed up while Outlook is running, that way user logon/logoff operations don’t need to be stalled
  2. It must be possible to transfer PST files to a backup location if the user is out of the office (not connected to corporate network)
  3. It must be possible to perform the transfer in a “resumable” manner, allowing the user to shut down or hibernate their machine and continuing any in-progress backups when the user logs back in.

To address the first item below, I created a Powershell script which uses Windows’ Volume Shadow Copy functionality to access the latest available snapshot of the PST files and copy them to a different location, even if they are locked by Outlook.

This article contains the script and some instructions on how it should be tailored for the environment where it is to be used.

The second and third points are addressed by setting the destination location of the script to be within the user’s DataNow cache. DataNow will detect the presence of the new files and begin to sync them in the background. If the user logs out or loses their network connection, the DataNow upload will pause and resume as necessary.

Once implemented in this way, the backup process will run as follows:

  1. A user logs in and opens Outlook
  2. Environment Manager fires the process start trigger for Outlook.exe and triggers the backup script
  3. The backup script determines that there are PSTs that need to be backed up by comparing the timestamps of the local PSTs with the timestamps of previous backups
  4. A VSS snapshot is created and the PSTs are copied from the snapshot into the backup location
  5. DataNow begins to sync the files to the server
  6. The VSS snapshot is removed to reclaim disk space on the client machine
  7. The user can continue working, safe in the knowledge that their PST files are being backed up automatically.


A Note for DataNow users who are redirecting My Documents

If Windows folder redirection is being used to redirect the Documents profile folder into DataNow and you’re using Office 2010 or later, a couple of extra configuration steps are required to prevent problems using this method.

If PST files are stored within the DataNow cache, for example in “Outlook Files” within a redirected “Documents” folder located in DataNow, they will fail to sync while they are locked by Outlook. For this reason the “Outlook Files” location should be excluded from sync as per this blog post on the topic.

The PSTs will reside locally and not be synced by DataNow until they are copied by the backup script into a folder which is not excluded from sync.

And that’s all there is to it

Obviously with some imaginative use DataNow, EM and this script could be used for all sorts of scenarios where locked files need to be moved around. Hopefully this example will inspire others to use AppSense products to design novel new solutions to age-old IT Admin problems. If anyone has any questions please post here or ask a question via the knowledgebase article linked above.