Robocopy Commands and Examples: The Ultimate Guide for Windows Backups and Sync

Robocopy (Robust File Copy) is one of the most powerful command-line tools provided by Microsoft.

In this guide, I’ll show you how to sync, move, backup, and—most importantlyaccelerate file transfers across your network!

Whether you are a sysadmin or a power user, Robocopy can handle heavy tasks that the standard Windows Explorer simply can’t.

Let’s dive in!

Robocopy: Commands and Examples Guide

robocopy commands and examples
Source: DevMedia

1. Basic Syncing and Mirroring

If you want to keep two folders identical, these are your essential switches:

  • /E: Includes all subdirectories (even empty ones).
  • /MIR: Mirrors a directory tree (it will delete files in the destination that no longer exist in the source).

Example:

In the command prompt, do:

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

Caution: Using /MIR will overwrite or delete files in the destination to match the source perfectly!!!

2. Copying over the Network (Windows & Linux/NAS)

When copying to a network share, logs are essential to track performance and errors.

Windows to Windows:

robocopy C:\Source \\WindowsServer\Share /E /MIR /LOG:C:\logs\transfer.log

Note: Use the colon after /LOG followed by the file path.

Windows to Linux (NAS/Samba): If your destination is a Linux-based server (like a Synology or TrueNAS), always add the /FFT switch.

robocopy C:\Source \\LinuxServer\Share /E /MIR /FFT /LOG:C:\logs\nas_sync.log

Why? /FFT (FAT File Times) provides better granularity for file timestamps between different file systems (NTFS vs. EXT4/XFS), avoiding unnecessary re-copying.

3. Moving Folders Faster

Don’t use “Cut and Paste” for large directories. Robocopy handles large data moves much more efficiently:

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

Always include /E to ensure subfolders are moved along with the files.

4. Copying Files by Date

Need to copy only recent files? Use /MAXAGE. For example, to copy files created or modified since November 22, 2022:

robocopy C:\Source D:\Destination /MAXAGE:20221122

Format: YYYYMMDD (Year/Month/Day).

5. Advanced Backup (Multi-threading and Resilience)

For professional backups, especially over unstable connections, use these parameters:

  • /ZB: Restartable mode (great for large files and network drops).
  • /R:5: Number of retries on failed copies (default is 1 million, which is too much! Set it to 5).
  • /W:10: Wait time between retries (10 seconds).
  • /MT:10: Multi-threaded copying. This speeds up the process significantly by copying multiple files (10 in this case) simultaneously.
  • /COPYALL: Copies all file info (Attributes, Timestamps, Security/ACLs). Note: Avoid /COPYALL when syncing between Windows and Linux.

Pro Backup Example:

robocopy \\Server\Source C:\LocalBackup /E /ZB /R:5 /W:10 /MT:32 /COPYALL /LOG:C:\logs\backup.log

Tip: You can set /MT up to 128 threads for maximum speed on modern CPUs (available on Windows 7 and newer).

“Reliable backups are the first step to system safety. But if your system is already failing to boot, you might need to reinstall it. Learn how to create a bootable USB to get your PC back up and running.”

6. Bandwidth Throttling (Limiting Network Usage)

When copying massive amounts of data during business hours, Robocopy can easily saturate your network bandwidth.

To prevent this from slowing down other users, you can use the /IPG (Inter-Packet Gap) switch.

This command adds a delay (in milliseconds) between network packets.

Example:

robocopy C:\Source \\NetworkServer\Share /E /IPG:125
  • How it works: Robocopy doesn’t have a “limit to 10MB/s” command. Instead, it uses /IPG. If you notice the network is getting slow, increase the value (e.g., /IPG:250). If you want it faster, decrease it.
  • Best Practice: This is particularly useful for backups running over VPNs or slow WAN links during the day.
0 0 votes
Article Rating
Subscribe
Notify of

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x