Robocopy: The Ultimate Guide to Windows File Copying and Automation

Robocopy in depth: mirroring, multi-threaded copies, NTFS permissions, logging and resumable transfers, with a backup script you can schedule.

Dhananjay AggarwalDhananjay Aggarwal, · 7 min read
Share
Summarize with AI
A yellow folder and a blue folder joined by circular sync arrows around the word Robocopy. From a post by Dhananjay Aggarwal.

Robocopy, short for Robust File Copy, is a powerful command line utility included in Windows. It is designed for high-performance file transfers, directory mirroring, scheduled backups and automated migrations. System administrators, DevOps engineers and power users prefer Robocopy for its reliability and advanced features.

In this article, we explore Robocopy in technical depth, with practical examples, key parameters, performance tips and real-world use cases.

What is Robocopy?#

Robocopy is a built-in Windows file replication tool with advanced copying capabilities. Unlike the traditional copy or xcopy commands, Robocopy can:

  • Handle network interruptions gracefully
  • Resume failed copies
  • Mirror complete directory structures
  • Copy NTFS permissions, attributes and ownership
  • Copy with multiple threads
  • Generate detailed logs for audits
  • Skip unchanged files to save time

Robocopy is included in all modern versions of Windows (Windows 7 and later) and in Windows Server editions.

Why Use Robocopy?#

People use Robocopy over copy or xcopy because it retries through network failures, copies with multiple threads, fits into scripts and scheduled tasks, and filters files in fine detail.

Robocopy is widely used for several reasons:

1. Reliability#

Robocopy retries file transfers and waits for the network to recover, which makes it ideal for large file migrations.

2. High performance#

With multi-threaded copying, Robocopy can significantly speed up transfers.

3. Automation friendly#

Robocopy commands fit into PowerShell scripts, scheduled tasks, batch jobs and CI workflows.

4. Granular control#

You can filter files by extension, age, size, attributes, timestamps, security permissions and more.

What Is the Robocopy Command Syntax?#

The Robocopy command syntax is the source folder, then the destination folder, then any options.

bat
robocopy <Source> <Destination> [Options]

Example:

bat
robocopy C:\Data D:\Backup /E

This command copies everything inside C:\Data into D:\Backup, including empty directories.

A source folder flowing through Robocopy into a destination folder. From a post by Dhananjay Aggarwal.
Source folder, Robocopy, destination folder

Example Usage and Practical Scenarios#

Most common Robocopy jobs need one switch: /E for subfolders, /MIR for mirroring, /MT for threads, /MAXAGE for recent files, /XF for exclusions, /COPYALL for permissions, /LOG for logs and /Z for resumable copies.

1. Copy all files and subfolders#

bat
robocopy C:\Source D:\Destination /E

/E copies all directories, including empty ones.

2. Mirror an entire directory#

bat
robocopy C:\Project D:\ProjectBackup /MIR

/MIR makes the destination an exact clone. Warning: it deletes files in the destination that do not exist in the source.

3. Multi-threaded copying for maximum performance#

bat
robocopy C:\Source D:\Destination /MT:16

Uses 16 threads for a faster transfer. The default is 8, and the maximum is 128.

4. Copy only files changed in the last 2 days#

bat
robocopy C:\Logs D:\LogsBackup /MAXAGE:2

5. Exclude specific file types#

bat
robocopy C:\Videos D:\VideosBackup /XF *.tmp *.bak

6. Copy NTFS permissions#

bat
robocopy C:\Secure D:\SecureBackup /COPYALL

/COPYALL copies file data, attributes, timestamps, ACLs, owner information and auditing rules.

7. Generate a detailed log file#

bat
robocopy C:\Data D:\Backup /E /LOG:C:\robocopy_log.txt

8. Restartable mode for unstable networks#

bat
robocopy \\Server1\Share \\Server2\Share /Z

/Z lets the copy resume after an interruption.

A Windows command prompt showing Robocopy output: the job header, three new files copied, and a summary table of directories, files and bytes with zero failures. From a post by Dhananjay Aggarwal.
Typical Robocopy console output

Real World Use Cases#

Robocopy is used for nightly scheduled backups, data migration between servers, versioned backups and configuration sync in build pipelines.

1. Automated daily backups#

Create a scheduled task that runs a Robocopy script every night.

2. Data migration between servers#

Sysadmins use Robocopy for seamless server upgrades.

3. Versioned backups#

Use log files and timestamps to keep historical snapshots.

4. DevOps file sync workflows#

Robocopy can plug into build pipelines for configuration sync.

How Do You Make Robocopy Faster?#

Robocopy gets faster with more threads, /MT:32 or /MT:64 if CPU resources allow, and by skipping unnecessary transfers with /XO and /XN.

  • Use /MT:32 or /MT:64 for faster copying if CPU resources allow
  • Avoid /MIR unless you want exact replication
  • Use /Z on unstable networks, but note that it can reduce speed
  • Use /LOG for audit trails
  • Combine /XO and /XN to skip unnecessary transfers

How Do You Schedule a Robocopy Backup?#

A scheduled Robocopy backup is a batch file that mirrors a folder with /MIR, copies with 32 threads, retries with /R:5 /W:2 and writes a log. Save it as backup.bat and schedule it.

bat
@echo off
set Source=C:\Projects
set Destination=D:\ProjectsBackup
set LogFile=C:\robocopy_fullbackup_log.txt

robocopy %Source% %Destination% /MIR /MT:32 /R:5 /W:2 /LOG:%LogFile%

Save this as backup.bat and schedule it.

Frequently asked questions#

What does robocopy /MIR do?

/MIR makes the destination an exact clone of the source. It deletes files in the destination that do not exist in the source, so avoid it unless you want exact replication.

How many threads does robocopy use?

Robocopy's /MT switch defaults to 8 threads and allows up to 128. /MT:32 or /MT:64 copies faster if CPU resources allow.

How do I copy NTFS permissions with robocopy?

Use /COPYALL. It copies file data, attributes, timestamps, ACLs, owner information and auditing rules.

Can robocopy resume an interrupted copy?

Yes. Restartable mode, /Z, lets the copy resume after an interruption. Use it on unstable networks, but note that it can reduce speed.

What is the difference between robocopy and xcopy?

Unlike copy or xcopy, Robocopy can handle network interruptions, resume failed copies, mirror directories, copy NTFS permissions, copy with multiple threads, write detailed logs and skip unchanged files.

Conclusion#

Robocopy is one of the most reliable tools for file transfer, backup automation and large-scale data migration on Windows. With multi-threaded copying, resumable transfers and granular filtering, it easily outperforms traditional file copy commands. Whether you are a system administrator, developer or power user, mastering Robocopy will noticeably improve your workflow.

If you are planning to automate backups or move large amounts of data on Windows, Robocopy should be your first choice. On Linux, the equivalent is rsync.

Found it useful? Clap for it.
Share
Summarize with AI
Prefer IntervueClub on GoogleShow our posts more often in Top Stories
Dhananjay Aggarwal

Written by Dhananjay Aggarwal

All posts