Windows is a great operating system, but sometimes it can be difficult to back up or copy files that are in use or locked in Windows. Here are some tips to help you backup or copy files that are in use or locked in Windows:

  1. Open the command prompt and type “cmd” (without the quotes).
  2. Type “backup” (without the quotes) and press Enter.
  3. Type “copy” (without the quotes) and press Enter.
  4. Type “quit” (without the quotes) and press Enter.

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:

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:

Using HoboCopy to Backup an Entire Directory

HoboCopy (c) 2006 Wangdera Corporation. hobocopy@wangdera.com

Starting a full copy from c:\users\geek\mail to d:\backups\Copied directoryBackup 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

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.

Syntax:

Let’s go with the same example, I want to backup my entire user directory to d:\backups, so I’d use this command:

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.

Syntax:

Example:

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.

Download HoboCopy from sourceforge.net