Backup/Copy Files that are "In Use" or "Locked" in Windows (Command Line)
If you’ve ever tried to copy a file that is locked by another application, you’ve probably seen an error message similar to “The process cannot access the file because another process has locked a portion of the file”. So how do you copy it anyway?

Since XP, Windows has supported a technology called Volume Shadow Copy, which is used to power the previous versions feature in Vista as well as System Restore and backups. What it does is take a temporary snapshot of the file or drive, and then allow an application to read from the snapshot even while other applications are accessing or modifying the file.
What we can do is use a command line utility called HoboCopy that utilizes this service to copy the file.
Understanding the Prerequisites
HoboCopy and most other backup utilities make use of two services in Windows, and you’ll need to verify that these services are not disabled:
- Volume Shadow Copy
- Microsoft Software Shadow Copy Provider
They can be left as Manual startup, so they don’t need to be running all the time. Hobocopy will start the two services automatically when needed, and the Volume Shadow Copy service will be turned back off after it’s done.
Using HoboCopy to Backup/Copy a Single File
The syntax is a little weird, because HoboCopy is really meant to be used for backing up an entire set of folders. We can use it to backup a single file by passing in the filename argument at the end.
Note: on Windows Vista you will need to launch an Administrator mode command prompt by right-clicking on the Command prompt in the start menu and choosing Run as Administrator.
Syntax:
hobocopy c:\directoryname\ d:\backupdirectory\ <filename>
For example, I want to backup my c:\users\geek\mail\outlook.pst file to d:\backups\outlook.pst. Here’s the syntax that I’d use:
C:\> hobocopy c:\users\geek\mail\ d:\backups\ Outlook.pst
HoboCopy (c) 2006 Wangdera Corporation. hobocopy@wangdera.com
Starting a full copy from c:\users\geek\mail to d:\backups\
Copied directory
Backup successfully completed.
Backup started at 2008-03-09 01:57:28, completed at 2008-03-09 01:58:39.
1 files (606.45 MB, 1 directories) copied, 7 files skipped
Using HoboCopy to Backup an Entire Directory
A much more useful task would be to backup my entire User folder, probably to an external hard drive for safekeeping. For this, we’ll want to add a couple of command-line arguments.
| /full | Copy all files |
| /skipdenied | Ignore any access denied messages because of permission errors. |
| /r | Copy recursively |
| /y | Don’t prompt, just copy everything |
Syntax:
hobocopy /full /skipdenied /y /r c:\directoryname\ d:\backupdirectory\
Let’s go with the same example, I want to backup my entire user directory to d:\backups\, so I’d use this command:
hobocopy /full /skipdenied /y /r c:\users\geek\ d:\backups\
This command will likely take a very long time to complete, so you might want to take a nap or something. At the end you should have a nearly perfect copy of the directory… if there are any permission errors you’ll be alerted to files that didn’t copy. Realistically any files in your user directory shouldn’t have this problem.
Using HoboCopy to Incrementally Backup a Drive
Hobocopy also supports backing up files incrementally, so it will only copy the files that have changed since the last backup. This works similarly to utilities like rsync, except hobocopy stores the last backup date in a file that you need to specify on the command line.
| /statefile=filename | This flag specifies the file that contains the last backup information. |
| /incremental | Only copy files that have changed since the last full copy. |
Syntax:
hobocopy /incremental /statefile=filename /y /r c:\directoryname\ d:\backupdirectory\
Example:
hobocopy /incremental /statefile=d:\lastbackup.dat /y /r c:\users\geek\ d:\backups\
The first time that you run this command you will need to use /full instead of /incremental, or else you will get an error because the state file hasn’t been created yet. After that you can run the incremental backup with the /incremental switch.
This would be an excellent way to automatically backup a set of folders as part of a scheduled task.

Daily Email Updates
You can get our how-to articles in your inbox each day for free. Just enter your name and email below:




Wow. I’ve always wondered how to do that… nice find, great article!
This is pretty cool… I guess hobocopy is a play on the name of robocopy.
Has anybody tried sending the backups to a network share on a samba box?
You say it works like rsync, but a timestamp to compare if a file has been changed is way different from rsync. rsync only copies the part of a file that has changed since the last time it was copied, not the entire thing if its timestamp is different.
Indeed. This sells rsync way short. If you have a 15 gb PST (Outlook Personal Folder file) and you want to back it up every day to a network share, hobocopy is going to copy the whole thing over the wire, possibly taking hours. rsync might get away with a few megabytes.
You guys are absolutely correct… I was just meaning that generally it keeps the directories in sync… I probably could have been more clear.
And I definitely would not recommend using HoboCopy across a network share… as jim and Ross mention, it’s going to copy the entire file every time, which would take forever.
I’m putting together an article on using rsync along with shadow copies, to give you the best of both worlds.
nice, that sounds cool
I just downloaded the file “HoboCopy-1.0.0.0-W2K3-Vista-32bit-Release.zip” and I am confused. The Geek says — and the HoboCopy READ.ME verifies — that this utility needs the MS Volume Shadow Service (VSS), included with Windows XP and above.
But if I look at the filename I see an abbreviation that must mean “Windows 2000 Professional, SP3.” Presumable the author of the utility knows its requirements, and I hope he’s right since I do run Windows 2000. But, how could it run, if it requires the VSS service?
Or, was there an earlier version that ran on Windows 2000, and the filename has been left unchanged?
@RonCam
“w2k3″ or “Win2k3″ are commonly used abbreviations for “Windows Server 2003″, not for Windows 2000. Sorry for the confusion!
The Geek, I am very interested in your forthcoming article in using Rsync with M$ Shadow Copy, if possible please keep me posted, thanks in advance.
Kind regards, Jim.
p.s. For what it’s worth, I use SyncToy for general sync and backup but this is not 100% accurate or reliable nor is M$ NTBackup!
gone through a bunch of readings then finally i came across this article… Small file but powerful…
you guys are really “The Geek”
thanks a lot.
try this…
CopySharp is a GUI tool for copying open/inprocess/lock files. It is inspired by robocopy and vshadow.
CopySharp V1.0 requires .Net Framework 3.5 and VC++ 2005 Runtime. CopySharp V1.0 requires Microsoft Windows Server 2003, Microsoft Windows XP.
For Example:
1. Try to backup/copy your .pst file(s), while your outlook is open.
2. Try to backup/copy your .mdf/.ldf (SQL Server) files, while your SQL Server is running.
Locate it at: http://www.amitchaudhary.com/
The Hobocopy link doesn’t work. Also, the app doesn’t run on two xp machines despite using the 32-bit program plus the c++ library helper.
The link should be fixed now.
then try CopySharp.
This is really nice tool. i like it.
however after creating full backup using statefile syntax,
if we add new file anywhere after full backup [in same location of which we have taken full backup]
and next time if we run /incremental switch along with statefile of last full backup, it skips this newly added file as their is no information of this newly added file in statefile.
how to overcome this.
I agree with Mithil. /incremental mode seems to be buggy. I does not copy any newly added files in the folder
I haven’t downloaded the program yet, but form what I have read on the original description and on this page it sounds great. But I just wanted to be sure I didn’t make a mistake. This program is supposed to be able to copy streaming video of flash?.
@Louis: This article is about backing up files on your computer not flash streaming. For saving streaming flash videos you can use something like Orbit downloader at http://www.orbitdownloader.com/
Can’t get this to work om my machine. Trying to copy my Windows.edb file and it just says that the file is being used by another process.
Starting a full copy from C:\Users\All Users\Application Data\Microsoft\Search\Data\Applications\Windows to c:\hej
Copy of file failed with error Det gr inte att komma t filen eftersom den anvnds av en annan process.
(Error number 32) on file \\?GLOBALROOT\Device\HarddiskVolumeShadowCopy33\Users\All Users\Application Data\Microsoft\Search\Data\Applications\Windows\Windows.edb
Nice, this is a real time saver. Appreciate the write up, thanks,
I’m trying to backup my windows, Program Files, Doc/Setting/Users directory on another harddrive in prep for a backup state that is setup.
I was thinking hobocopy can do this. What tool makes this possible, so instead of reinstalled OS, and reinstalling all my programs, I can just take the state of my system files, and copy from BUdrive to c:\ when c:\ and it’s OS gets plugged up and needs reinstall.
Any ideas on this?
hobocopy has a problem when your source path has a space in the address under Vista – make sure you change your temp file location!!!
hobocopy has also problem copying from windows temporary folder. Here is the output of my cmd prompt;
C:\>HoboCopy.exe c:\Work\temp\delme\ C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp fla60.tmp
HoboCopy (c) 2006 Wangdera Corporation. hobocopy@wangdera.com
Starting a full copy from c:\Work\temp\delme\ to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
Copied directory
Backup successfully completed.
Backup started at 2009-10-20 20:41:27, completed at 2009-10-20 20:41:30.
0 files (0.00 bytes, 1 directories) copied, 0 files skipped