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

2 Replies to “Backing Up Locked Files”

  1. Your robocopy command incorrectly refers to the C: volume instead of the B: volume you just mapped and is missing the “\”.

    robocopy “C:documents and settings” ..
    should be
    robocopy “b:\documents and settings”

    1. Thanks, I updated the post to replace the missing \’s. On a second pass through, I think you are right. I changed the C: to B:, although I could swear that I copied this right from our migration script, but looking at other examples on the Internet I think you are right.

      The reason the “\’s” are missing, is because I transferred web hosts and when I imported the WordPress backup database, it chopped off a lot of the \’s. I just haven’t had the chance to go back and edit all the posts I made. Although to be honest: even if you copy and paste code from the Internet, a lot of times you end up removing these extraneous formatting characters with Notepad++ anyways, so hopefully it should be obvious where the \’s were chopped out.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.