Copy locked files with Robocopy using /B parameter

Posted on 2007-06-26
Last Modified: 2012-11-09
I want to use the robust file copy utility Robocopy to backup the workstation of my small office network.

The problem is this utility does not allow to copy files locked especially the files PST of Outlook.

I am amazed because Robocopy allows the parameter / B which makes a copy in backup mode. But even with this parameter I have an error " ERROR 32 ( 0x00000020 ) ".

What is necessary to make Robocopy able to copy locked files ?

Any help will be very appreciated
Question by:Bulle
  • 4
  • 2
  • 2
  • +5
LVL 66

Expert Comment

ID: 19365341
Robocopy doesnt copy open files, as you would need a normal Backup Software suite.

Backup of open files

Robocopy does support the /c swithc which allows continuing on errors but that kinda defeats the purpose of a backup in the first place.....
LVL 66

Expert Comment

ID: 19365367
There are other methods of backing up .pst files though.....

Script to schedule your pst-file back-up

Download details: Outlook 2003/2002 Add-in: Personal Folders Backup
LVL 26

Expert Comment

ID: 19365442
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

LVL 70

Expert Comment

ID: 19365787
Robocopy cannot copy locked files - try syncback if you want a nice ptogram that can

Expert Comment

ID: 19368109
If there is one thing I've learned in IT it's that everything is possible!

Craig Andera wanted to do the same sort of thing so he came up with his own solution based on the Volume Shadow Copies services built into Windows Server 2003 / XP. It is clearly indicated on Craig's site that this is a hobby project, but it may be worth a try and if it works...

Accepted Solution

ajbritton earned 460 total points
ID: 19368118
There is also this ( which is a bit complex, but could be useful to someone with the same problem who is handy in the scripting field.

Author Comment

ID: 19370405
Thanks to all for these answers,
I had already seen Hobocopy which seems to me be good solution. However I find the following defects to the program:
 1. / incremental require a file (via the parameter / statefile) and I do not know how to create this file the first time. Why the program does not look simply at the date of modification in the directory of destination to decide if the file must be copied or not ?
 2. We cannot exclude directories

I also discovered a freeware program which allows to unlock a file (, it is possible to use this program in a script to unlock a file before its copy.

But I would like to know the utility of the / B parameter in Robocopy. Why does this parameter exists?


Expert Comment

ID: 19371233
The /B tells robocopy to copy the file in 'backup' mode which is a special file access method designed to allow the backup of a file by users who do not have read access to the file.

I would not recommend unlocking a file prior to backing it up unless you are 110% sure the file will not be modified whilst it is being copied.

Looking at hobocopy, I think the the statefile is created for you when you do an initial copy, which would be necessary before attempting incrementals.

One messy (and probably slow) solution would be to write a script which processes the directory structure in a recursive way, calling hobocopy once at each directory level. You could then do your own filtering. I would think it probably easier to implement the method mentioned in my 2nd post though.

Author Comment

ID: 19479127
Hello everybody,
after spending hours to find what I was expeced, I finally found THE solution.
As explained in this blog by Adi Oltean, I use VShadow.exe to create shadow copy of my volume and map a drive letter (as explained in this blog before to access it with Robocopy. It was exactly what I expeced, using Robocopy with Volume Shadow Copy Service. Yet I've created an installer with NSIS which creates all the scripts and the scheduled task so each time I install a new machine I just have to launch the installer and everything is automatic.
I perhaps will use rsync instead of Robocopy to relieve network traffic. I will perhaps study this option later.
Many thanks to ajbritton who put me on the way to find the solution. I like the way you introduce your first answer : "If there is one thing I've learned in IT it's that everything is possible!" I totally agree with you, in IT everything is possible, it is only a question of patience and determination.

Expert Comment

ID: 19479203
Glad to hear that you got it sorted.

Expert Comment

ID: 21515133
try this...

CopySharp V1.0 is a GUI tool for copying open/in process files.
It is inspired by robocopy and vshadow.

CopySharp V1.0 requires Microsoft® Windows® Server 2003, Microsoft® Windows® XP

I have lots of issues posted over net regarding copying/renaming/moving of files fails due to the no of reasons like file is in process or opened by some application etc.

For example:
On going to the location of the .pst file, I can rename, but not copy or move. "Error 0x80070021: The process cannot access the file because another process has locked a portion of the file."

There are no processes using this file as I have tried to access the same file from another computer to the network drive. I have also tried to use "unlocking" tools which say the file is not locked by any process.

CopySharp addresses the same issue. And can easily copy the same kind of files.

Locate it at:
LVL 16

Expert Comment

ID: 23495131

Expert Comment

ID: 38584378
We have been through the same thing and after countless hours of evaluating different tools, we stumbled across gscopy pro.  It backs up open files and locked files with no issues.
Other utilities were a bit buggy in some way or shape but I guess this is what you get when it is free :(

Try gscopy pro.

Good Luck

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
outlook and exchange information 3 34
Scheduled Tasks Tweak 5 30
Unable to Uninstall Visual Studio 2015 7 26
Reinstall Windows 10 3 17
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question