Backing Locked Windows Files Using Robocopy
Background
Robocopy is a great synchronization tool for Windows. However, occasionally it is unable to copy locked files. An example of when this is particularly aggrevating is when you want to backup your Outlook mail (i.e., PST files) with Outlook still open.
So, this HOWTO details how to automatically copy locked files with robocopy as well as how to schedule the backup in Windows.
HOWTO
- Download VShadow which is inclued in the Windows Software Development Kit (SDK). This tool is used to create a shadow copy of a drive.
- Download dosdev. This tool is a wrapper for a Win32 API that allows you to assign a drive letter to your shadow drive.
- Create a script to be used by vshadow to (1) create a driver letter for the shadow drive, (2) call the robocopy command, and (3) cleanup the shadow drive letter. You can download my script (TXT link) and adjust as needed for you file/directory structure.
- Create a script that calls vshadow and references the script created in the previous step (e.g., vss_exec.cmd). You can download my script (TXT link) and adjust as needed for you file/directory structure.
- Optionally, if you want to automate this backup, you can use Windows task scheduler to call your vshadow script at a scheduled time. Note if you get an "Access denied" error in XP, this link details a workaround.