Backing Up Locked Files

One of the challenges of migrating someone from one computer to another is the data they may have on the C: drive, especially those evil PST files.  The major challenge is backing up locked files.  We can get around this by using VSC in Windows.  Starting with Windows XP, VSC or Volume Shadow Copy allows Windows to “freeze” the state of the file system in time and then copy files/folder in this frozen state.  We will use the freeware program VSCSC to tap into this power.

First we use Mapper24 to encrypt/hide the credentials for the service account that will connect to our server:

mapper24.exe <some encrypted chars> domainusername \serverbackup

Next, we make a folder with the name of the computer we are running from:

 mkdir \serverbackup\%computername%

Then we kick off VSCSC:

vscsc -exec=wkxp2.cmd C:

In wkxp2.cmd, we have this:

robocopy “B:\documents and settings\serverbackup\%computername%” /B /MIR /R:0 /XF *.ost *.tmp *.bak *.dat *.mp3 /XD “Local Settings” “Temp” “Cookies” “Recent” “Nethood” “Printhood” “SentTo” “Start Menu”

So here is what we are doing…we are creating a snapshot in time, then we can use any copy program we want to copy files when “time is frozen” within this snapshot.  Once we exit the script, VSCSC exits and the snapshot is gone.  In the above robocopy script: I am telling it to exclude folders like Local Settings since that is where the internet temporary files are stored.  And yes: this will copy ALL user profiles on the computer to the server, not just the one we want, so you will have to pick through the profiles and grab what you want.

We can log in as the new user on the new computer and just drop in the Desktop, Favorites and My Documents folders manually from the server.

Note that vscsc doesn’t seem to work on Windows 7.  For Windows 7 you will need to copy Diskshadow from Server 2008 or 2008R2 or as a download from here:  Copy the contents of the ZIP file to System32, including the en-US folder or it will not work properly. The concept is pretty much the same:

set context persistent nowriters
set metadata C:\windows\temp\
set verbose on
begin backup
add volume C: alias C_Drive
expose %C_Drive% X:
exec yourbatchfile.cmd
delete shadows volume C:
unexpose X:
end backup

Update (12/21/16): As an update to this article, I find that ShadowSpawn to be superior to the above method and a lot easier.  Essentially, it’s copy 2 files over and run one command line to copy files.  As an example you could do something like:

shadowspawn C:\archives X: xcopy X:\*.pst C:\path\to\backup 

– Soli Deo Gloria