I want to build a backup script using robocopy, but I haven't found any info on why I can't copy files that are open in another program when backing up C: to F:.

I've tried the below, but it's stuck on one file that is open by another program:

RoboCopy "C:/" "F:/" /E

What attributes should I use to skip directories %WinDir% and Windows.old, as well as only copy changed files?


RoboCopy will be extremely inefficient at backing up a drive, and would not be recommended in any use case I can think of.


  • For Windows >8, DISM would be utilized to capture an image (WIM) of a drive:

    DISM /Capture-Image /ImageFile:"Z:\Base.wim" /CaptureDir:"C:" /Name:"Windows Backup" /Description:"Base Image 2017.07.14 @ 20:30" /Compress:Max /CheckIntegrity /Verify /NoRpFix /ScratchDir:"Z:\"
    • /ScratchDir is required, else the capture will likely fail since WinPE/WinRE only has 32MB of scratch [temp] space set aside for it by default.

  • In Windows <7, ImageX would be utilized in lieu of DISM.

    ImageX /Capture "C:" "Z:\Base.esd" "Windows Backup" "Base Image 2017.07.14 @ 20:30" /Compress:Recovery /Check /Verify /NoRpFix /ScratchDir:"Z:\"


  • It's impossible for an ESD/WIM image to become corrupted
    • Provided imaging commands are always issued with:
      • Windows >8: /CheckIntegrity & /Verify
      • Windows <7: /Check & /Verify

  • ESDs can only be taken of a system partition
    • /Compress:Recovery is the only compression algorithm available.
      • ESD compression ratio is ~33% more efficient than the WIM compression ratio.

  • ESDs/WIMs are smart compression image formats
    • Only changed files are added to an image when a new image is appended to it
      • Newly appended images utilize the same copy of unchanged files already contained within the image from the previous image(s).
        • This allows for an image to remain small in relation to the data contained within.

DISM Prerequisites

| improve this answer | |

Robocopy has option /XD for excluding a list of directories:

/XD "C:\Windows" "C:\Windows.old"

You can get a list of robocopy commands, creating a text file on your desktop via:

Robocopy /? > "%USERPROFILE%\desktop\robocopy_commands.txt"
  • If you want a current backup where both copies are identical, use the /MIR to "mirror" the versions, which will delete files on the backup copy (destination) that are no longer present on the original copy (source); /MIR is a short-hand combination of /PURGE and /E.
  • If you use the /L option, this will list what will happen, but won't actually do the move or copy, which is useful for testing your script before actually taking the time to copy stuff.
  • Robocopy, at least when using /MIR, is restartable and does not re-copy things which have not changed.

To avoid massive slowdowns from problems opening or accessing files, I usually set the retries to some small number and the retry wait to a small interval, like /R:2 /W:2, and then check the log file for failures, handling those manually.

| improve this answer | |
  • hey, what the option for skip "open\ise files"? – itzikb Oct 26 '16 at 6:21
  • there isn't one. Use the retry and wait options as I suggested above so that the copy process will just move on. The default retry is something like 1 million. Set it to 1 or 2. The wait between retires is 30 seconds. set it to 1 or 2. Also, read the documentation. – Yorik Oct 26 '16 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.