Skip to main content
HTREASURE LTD

Data backup

How to Back Up Folders with Robocopy in Windows

Use Robocopy, the free copy tool built into Windows, to back up and mirror folders reliably, with example commands, logging and the mistakes to avoid.

Published

Back up folders with Robocopy – HTREASURE LTD guide

Robocopy ("robust file copy") is a command-line tool built into Windows. It copies large numbers of files reliably, resumes after network interruptions and only copies files that have changed. That makes it a handy free backup tool for folders.

A basic Robocopy backup

Open Command Prompt or PowerShell and run:

robocopy "C:\Users\You\Documents" "E:\Backup\Documents" /E /R:2 /W:5

  • /E copies all subfolders, including empty ones.
  • /R:2 retries a failed file twice (the default is a million retries).
  • /W:5 waits five seconds between retries.

Run it again later and Robocopy only copies new or changed files.

Mirroring a folder (use with care)

/MIR makes the destination an exact mirror of the source:

robocopy "C:\Data" "E:\Backup\Data" /MIR /R:2 /W:5

Warning: /MIR also deletes files in the destination that are no longer in the source. If you delete a file by mistake, or ransomware damages your files, the next mirror copies that loss to your backup. Keep a separate versioned or off-site backup as well.

Test first with /L

Add /L to list what Robocopy would do without copying or deleting anything. Always do this when you change a command, especially one using /MIR.

Keep a log

Add /LOG:"E:\Backup\robocopy.log" to write the results to a file (or /LOG+: to add to an existing log). Check the summary at the end for failed files.

Speed it up

/MT:8 copies eight files at a time, which can speed up backups of many small files.

Understanding exit codes

Robocopy's exit codes are unusual: codes 0 to 7 mean success (for example 1 means files were copied), while 8 or higher means some files failed. Remember this if you use Robocopy in a script.

Run it automatically

Save your command in a .bat file and schedule it with Task Scheduler to run daily. Choose "Run whether user is logged on or not" so it runs in the background.

Frequently asked questions

Does Robocopy copy open files?

It can skip files that are locked by other programs. Close programs such as accounting software or Outlook before the backup, or use backup software that supports Volume Shadow Copy.

Is Robocopy a complete backup solution?

It is a good copying tool, but it does not keep versions, encrypt or verify backups. Combine it with the [3-2-1 backup rule](https://htreasure.com/blog/3-2-1-backup-rule-small-business).

Related products

Browse our [backup and recovery utilities](https://htreasure.com/shop/category/backup-and-recovery).