robocopyRobocopy Command: Robust File Copy Tool | Windows Guide
Learn how to use robocopy for advanced file copying, directory mirroring, network transfers, and backup automation in Windows. Complete guide with examples.
The robocopy command (Robust File Copy) is a Windows Command Prompt utility designed for reliable file and directory copying with advanced features including resumable transfers, retry logic, mirroring, filtering, and logging. Use robocopy for network file transfers that survive interruptions, automated backup solutions, directory synchronization, and enterprise file migrations that require verification and detailed logging.
Whether you're a system administrator synchronizing file servers across offices, an IT professional migrating terabytes of data with network interruptions, or automating nightly backups with retention policies, Robocopy provides enterprise-grade file copying capabilities far beyond the basic copy command. Network administrators rely on Robocopy for its ability to resume interrupted transfers, preserve NTFS permissions and attributes, handle long paths, and provide detailed logging for compliance and troubleshooting.
This comprehensive guide covers Robocopy command syntax, essential switches for common scenarios, practical examples for backup and migration tasks, troubleshooting tips for transfer failures, related file management commands, and frequently asked questions. By the end, you'll confidently deploy Robocopy for production file operations across Windows networks.
What Is the Robocopy Command?
The robocopy command is Microsoft's advanced file copy utility included in Windows Vista and later (available as a download for Windows XP/2003). Unlike the basic copy and xcopy commands, Robocopy handles network interruptions, automatically retries failed operations, preserves NTFS security attributes, and provides comprehensive logging—making it the standard tool for enterprise file operations.
Robocopy runs from Command Prompt or PowerShell on all modern Windows versions including Server editions. The command doesn't require special privileges for basic file copying but needs administrator rights to copy security descriptors, ownership, and audit information. Robocopy's design philosophy emphasizes reliability: it verifies each file copy, maintains detailed logs, and automatically handles transient network errors that would cause basic copy commands to fail completely.
The most common usage pattern is robocopy source destination [files] [options], where powerful switches control copying behavior including recursion depth, file filtering, attribute preservation, retry logic, and bandwidth throttling for WAN transfers.
Syntax
robocopy <source> <destination> [file...] [options]
Essential Options
| Switch | Description |
|---|---|
/E | Copy subdirectories including empty ones (full recursion) |
/MIR | Mirror directory tree (copy + delete files not in source) |
/COPYALL | Copy all file information (data, attributes, timestamps, NTFS ACLs, owner, audit) |
/DCOPY:DAT | Copy directory timestamps, attributes, and permissions |
/R:n | Number of retries on failed copies (default 1 million) |
/W:n | Wait time between retries in seconds (default 30) |
/LOG:file | Output status to log file (overwrite existing) |
/LOG+:file | Output status to log file (append to existing) |
/MT[:n] | Multi-threaded copying with n threads (default 8, max 128) |
/Z | Copy files in restartable mode (survives interruptions) |
/B | Copy files in backup mode (bypass security) |
/SEC | Copy files with security (NTFS ACLs) |
/XO | Exclude older files (skip if destination newer) |
/XF file | Exclude files matching names/paths/wildcards |
/XD dir | Exclude directories matching names/paths |
/MAX:n | Maximum file size to copy (n bytes) |
/MIN:n | Minimum file size to copy (n bytes) |
/MAXAGE:n | Maximum file age (n days) |
/MON:n | Monitor source and run again when n changes detected |
/MOT:m | Monitor source and run again after m minutes |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | No files copied, no failures, no mismatches |
| 1 | Files copied successfully |
| 2 | Extra files or directories detected in destination |
| 4 | Some mismatched files or directories detected |
| 8 | Some files or directories could not be copied (copy errors) |
| 16 | Serious error (insufficient disk space, access denied, etc.) |
Parameters Explained
/E – Copy All Subdirectories
The /E switch copies all subdirectories including empty ones, performing complete directory tree replication. This is essential for full directory backups where empty folders must be preserved for application compatibility.
Example: robocopy C:\Source D:\Backup /E
Without /E, only files in the root directory are copied—subdirectories are ignored completely.
/MIR – Mirror Directory
The /MIR (mirror) switch combines /E (copy subdirectories) with deletion of files in destination that don't exist in source. This creates an exact mirror, making destination identical to source.
Example: robocopy C:\Source D:\Backup /MIR
⚠️ WARNING: /MIR deletes files from destination! Use cautiously—it permanently removes destination files not present in source.
/MT – Multi-Threaded Copying
The /MT switch enables multi-threaded file copying, significantly accelerating operations on modern multi-core systems and high-bandwidth networks. Specify thread count or use default of 8 threads.
Example: robocopy C:\Source D:\Backup /E /MT:16
This uses 16 threads for simultaneous file copies, dramatically improving performance on large file sets.
/Z – Restartable Mode
The /Z switch copies files in restartable mode, allowing interrupted transfers to resume from the point of failure rather than restarting from the beginning. Essential for large files over unreliable networks.
Example: robocopy \\Server\Share C:\Local\Data /E /Z
Network interruptions won't require complete file re-transfers. Robocopy resumes where it stopped.
/LOG – Detailed Logging
The /LOG switch creates comprehensive logs of all Robocopy operations including files copied, skipped, failed, and detailed statistics. Critical for troubleshooting and compliance documentation.
Example: robocopy C:\Source D:\Backup /E /LOG:C:\Logs\backup.log
The log file contains complete details of the operation for audit trails and diagnostics.
Examples
Basic Directory Copy with Subdirectories
Scenario: You need to copy an entire project directory including all subdirectories and files from one location to another on the same computer.
robocopy C:\Projects\MyApp D:\Backup\MyApp /E
Expected Output:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Sunday, February 15, 2026 2:30:15 PM
Source : C:\Projects\MyApp\
Dest : D:\Backup\MyApp\
Files : *.*
Options : *.* /DCOPY:DA /COPY:DAT /E /R:1000000 /W:30
------------------------------------------------------------------------------
52 C:\Projects\MyApp\
*EXTRA Dir -1 D:\Backup\MyApp\old_version\
New File 1024 readme.txt
New File 51200 app.exe
Newer 2048 config.ini
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 52 52 0 0 0 1
Files : 847 245 600 2 0 3
Bytes : 45.2 GB 12.3 GB 32.8 GB 1.2 MB 0 500 KB
Times : 0:05:23 0:04:15 0:00:10 0:00:58
Speed : 52857234 Bytes/sec.
Speed : 3024.841 MegaBytes/min.
Ended : Sunday, February 15, 2026 2:35:38 PM
Explanation: Robocopy copies all files and subdirectories, skipping files that already exist and are identical. The summary shows exactly what was copied, skipped, and any errors.
Mirror Directory (Exact Replica)
Scenario: You maintain a backup drive that must be an exact mirror of your work drive, including deletion of files removed from the original.
⚠️ WARNING: /MIR deletes files from destination!
robocopy C:\Work D:\WorkBackup /MIR /LOG:C:\Logs\mirror.log
Expected Output:
Options : *.* /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30 /LOG:C:\Logs\mirror.log
*EXTRA File 25600 D:\WorkBackup\old_document.docx
[Deleted]
Explanation: /MIR ensures destination is identical to source by copying new/changed files AND deleting files that don't exist in source. The log file documents all operations.
Copy with NTFS Permissions and Attributes
Scenario: You're migrating user data to a new file server and need to preserve all NTFS permissions, ownership, timestamps, and audit information.
robocopy \\OldServer\Users \\NewServer\Users /E /COPYALL /B /DCOPY:DAT /R:3 /W:10 /LOG:C:\Logs\migration.log
Expected Output: Full directory copy with all security descriptors, ACLs, owner information, and timestamps preserved.
Explanation: /COPYALL copies all file attributes including security. /B enables backup mode to bypass security restrictions (requires admin rights). /DCOPY:DAT copies directory attributes. /R:3 /W:10 retries 3 times with 10-second waits.
Network Transfer with Resume Capability
Scenario: You're copying 500GB of data over a WAN connection that occasionally drops. You need transfers to automatically resume without restarting from scratch.
robocopy \\RemoteServer\Data C:\LocalData /E /Z /MT:8 /R:10 /W:30 /LOG+:C:\Logs\transfer.log
Expected Output: Files copy with automatic retry on network failures, resuming interrupted transfers from the point of failure.
Explanation: /Z enables restartable mode for resuming interrupted transfers. /MT:8 uses 8 threads for parallel copying. /R:10 /W:30 retries 10 times with 30-second waits. /LOG+ appends to log file for continuous monitoring across multiple runs.
Exclude Specific Files and Directories
Scenario: You're backing up a project directory but need to exclude temporary files (*.tmp), log files, and the "node_modules" directory which contains thousands of dependency files.
robocopy C:\Projects D:\Backup /E /XF *.tmp *.log /XD node_modules .git /LOG:C:\Logs\backup.log
Expected Output: All files and directories copied except *.tmp, *.log files and node_modules, .git directories.
Explanation: /XF excludes files matching patterns (supports wildcards). /XD excludes directories by name. This dramatically reduces backup time by skipping unnecessary files.
Copy Only Files Modified Today
Scenario: You need to copy only files modified in the last 24 hours for incremental backup purposes.
robocopy C:\Source D:\Backup /E /MAXAGE:1 /LOG:C:\Logs\daily.log
Expected Output: Only files with modification dates within the last 1 day are copied.
Explanation: /MAXAGE:1 limits copying to files 1 day old or newer. Useful for daily incremental backups where only recent changes need to be copied.
Automated Backup Script with Retention
Scenario: You're creating a batch script for nightly backups that maintains weekly retention, logging all operations for compliance.
@echo off
set SOURCE=C:\Data
set DEST=D:\Backups\%date:~-4,4%-%date:~-7,2%-%date:~-10,2%
set LOG=C:\Logs\backup-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%.log
robocopy "%SOURCE%" "%DEST%" /E /COPYALL /R:3 /W:10 /LOG:"%LOG%" /NP /TEE
if %ERRORLEVEL% LSS 8 (
echo Backup completed successfully
) else (
echo Backup failed with errors - check log
)
Expected Output: Daily timestamped backup directories with full logs.
Explanation: Creates date-stamped backup folders, copies with full attributes, logs operations, and checks exit codes for success/failure. /NP disables progress percentage (cleaner logs), /TEE outputs to console and log file.
Multi-Threaded Large File Transfer
Scenario: You're copying a 2TB video archive to a new storage array and need maximum speed using all available CPU cores and network bandwidth.
robocopy E:\VideoArchive F:\NewStorage /E /MT:32 /R:3 /W:10 /LOG:C:\Logs\video-transfer.log /NP /NDL /NFL
Expected Output: Extremely fast transfer using 32 parallel threads.
Explanation: /MT:32 uses 32 threads for massive parallelization on high-performance systems. /NP disables percentage (improves performance), /NDL (no directory list) and /NFL (no file list) reduce log file size for huge operations.
Synchronize Two Directories
Scenario: You need to keep two directories synchronized—copying new and updated files in both directions without deleting anything.
robocopy C:\Dir1 C:\Dir2 /E /XO /LOG:C:\Logs\sync1to2.log
robocopy C:\Dir2 C:\Dir1 /E /XO /LOG:C:\Logs\sync2to1.log
Expected Output: Both directories contain all files from both sources, with newest versions preserved.
Explanation: /XO (exclude older) skips files where destination is newer, preventing overwriting newer files with older versions. Running both directions creates two-way sync without destructive deletion.
Monitor and Auto-Run on Changes
Scenario: You need Robocopy to continuously monitor a source directory and automatically copy changes when they occur for real-time replication.
robocopy C:\Source D:\Replica /E /MON:5 /LOG+:C:\Logs\monitor.log
Expected Output: Robocopy stays running and triggers a new copy operation every time 5 or more files change in source.
Explanation: /MON:5 monitors source and runs again when 5 changes are detected. Use /MOT:m instead to run every m minutes regardless of changes. This creates continuous replication. Press Ctrl+C to stop monitoring.
Common Use Cases
-
Automated Nightly Backups: Schedule Robocopy in Task Scheduler for daily backups with retention policies, comprehensive logging, and email alerts on failure—far more reliable than basic copy commands for production environments.
-
File Server Migration: Migrate terabytes of data between file servers while preserving NTFS permissions, ownership, timestamps, and audit information—critical for maintaining security context in enterprise environments.
-
Directory Mirroring for Disaster Recovery: Maintain exact replicas of critical directories on separate storage or remote locations using
/MIRfor complete disaster recovery capability with automated synchronization. -
Network File Transfers with Unreliable Connections: Copy large files over VPN or WAN connections that frequently disconnect, using
/Zrestartable mode to resume from interruption points without restarting entire transfers. -
Project Directory Synchronization: Keep development environments synchronized between workstations, excluding build artifacts and temporary files with
/XFand/XDfor efficient multi-location development. -
User Profile Migrations: Migrate user profiles during workstation refreshes while preserving all registry hives, AppData contents, and NTFS permissions required for proper application function post-migration.
-
Incremental Backup Solutions: Implement incremental backup strategies using
/MAXAGEto copy only recently modified files, dramatically reducing backup time and storage requirements while maintaining complete data protection. -
Video and Media Asset Management: Transfer large video files and media libraries between editing workstations and storage arrays using multi-threaded mode for maximum performance on high-bandwidth networks.
-
Database Backup Verification: Copy SQL Server backup files to remote locations with verification and detailed logging for compliance, using retry logic to handle transient storage array issues during backup windows.
-
Software Deployment and Distribution: Distribute application installers and updates to multiple remote locations with automated retry logic, ensuring consistent software availability across geographically distributed offices.
-
Email Archive Management: Migrate and consolidate PST files and email archives between storage locations while preserving timestamps critical for compliance and litigation hold requirements in enterprise environments.
-
Long-Path File Support: Copy directory structures exceeding Windows' 260-character path limit using Robocopy's native long-path support, resolving issues where Explorer and basic copy commands fail with "path too long" errors.
Tips and Best Practices
-
Always Test with /L First: Use
/L(list only) to simulate operations without copying:robocopy source dest /E /L. This shows exactly what would be copied/deleted without making changes—essential before/MIRoperations. -
Use /LOG for Production Operations: Always specify
/LOGor/LOG+for production Robocopy operations. Logs provide troubleshooting data, compliance documentation, and transfer verification. Store logs centrally for long-term retention. -
Understand /MIR Implications:
/MIRdeletes files from destination! Never use/MIRon destinations containing unique files. Test thoroughly with/Lfirst. Consider/Ewithout/MIRfor safer operations. -
Adjust Retry Logic for Network Conditions: Default
/R:1000000(1 million retries) can cause operations to hang indefinitely on persistent errors. Use reasonable values:/R:3 /W:10(3 retries, 10-second wait) for faster failure detection. -
Use /MT for Large File Sets: Multi-threaded mode dramatically improves performance on modern systems. Use
/MT:16or/MT:32for copying thousands of files. Single-threaded mode can be 10-20x slower. -
Specify /DCOPY:DAT for Directory Attributes: By default, Robocopy doesn't copy directory timestamps. Add
/DCOPY:DATto preserve directory attributes, timestamps, and security descriptors for complete directory replication. -
Monitor Exit Codes in Scripts: Robocopy exit codes indicate operation status. Code 0-1 = success, 2 = extras detected, 4 = mismatches, 8+ = errors. Check
%ERRORLEVEL%in batch scripts:if %ERRORLEVEL% LSS 8 (success). -
Use /XO for Synchronization: When synchronizing directories without deletion, use
/XO(exclude older) to prevent overwriting newer destination files with older source files—essential for two-way sync scenarios. -
Exclude Large Unnecessary Directories: Use
/XDto exclude directories like node_modules, .git, bin, obj that contain thousands of files unnecessary for backups. This reduces backup time from hours to minutes. -
Combine /Z with Network Transfers: For any network copy operation (especially WAN), use
/Zfor restartable mode. Network interruptions won't require complete re-transfers—Robocopy resumes from the failure point. -
Use /NP for Scheduled Tasks: Add
/NP(no progress) when running Robocopy from Task Scheduler. Progress percentage causes excessive logging and performance degradation in automated scenarios. -
Document Robocopy Scripts: Comment batch files thoroughly documenting source, destination, purpose, and switch meanings. Robocopy syntax is complex—clear documentation prevents mistakes during maintenance and troubleshooting.
Troubleshooting Common Issues
"Access Denied" Errors on Specific Files
Problem: Robocopy reports "Access denied" for certain files, causing ERROR 5 entries in log files and incomplete backups.
Cause: Insufficient permissions to read source files or write to destination, NTFS ACLs blocking access, or files locked by applications.
Solution:
- Use
/B(backup mode) to bypass security checks:robocopy source dest /E /B(requires admin rights) - Close applications locking files
- Run Command Prompt as administrator
- Use
/SECor/COPYALLonly if you have permissions to read security descriptors
Prevention: Always run Robocopy as administrator for system file operations. Use /B for copying files with restrictive ACLs. Test with limited file sets before full operations.
Robocopy Hangs or Runs Indefinitely
Problem: Robocopy appears to hang with no progress for hours, consuming CPU but not completing operations.
Cause: Default /R:1000000 (1 million retries) causes indefinite retry loops on persistent errors like network disconnection or locked files.
Solution:
- Press Ctrl+C to stop Robocopy
- Re-run with reasonable retry limits:
/R:3 /W:10(3 retries, 10-second wait) - Check log file to identify problem files
- Exclude problematic files/directories with
/XFor/XDif they're causing persistent failures
Prevention: Always specify reasonable /R and /W values for production scripts. Default retry behavior is inappropriate for automated operations requiring timely completion.
"The File Exists" Errors on Long Paths
Problem: Robocopy fails with "The file exists" errors when copying deeply nested directory structures with long path names.
Cause: Some Robocopy versions have issues with paths exceeding 256 characters despite Robocopy being designed for long-path support.
Solution:
- Update to latest Windows version with current Robocopy version
- Use shorter destination paths (map network drives to reduce path length)
- Restructure source directories to reduce nesting depth if possible
- Use
/256switch to enable long-path support explicitly
Prevention: Plan directory structures to avoid excessive nesting. Map network shares to drive letters to reduce path lengths before copying.
Exit Code 8 – Copy Errors Occurred
Problem: Robocopy completes but returns exit code 8, indicating copy errors occurred. Some files were not copied.
Cause: Specific files failed to copy due to access denied, locked files, disk space issues, or network problems. Not all files were transferred successfully.
Solution:
- Review log file to identify failed files:
findstr /C:"ERROR" logfile.txt - Address specific issues (close applications, fix permissions, free disk space)
- Re-run Robocopy to copy missed files (Robocopy will skip already copied files)
- Use
/R:0to disable retries on problematic files and complete operation, then handle errors manually
Prevention: Use /B for permission issues, ensure adequate disk space, close applications before copying, use reasonable /R:n values.
Destination Files Have Wrong Timestamps
Problem: After Robocopy completes, destination files have current timestamps instead of original timestamps from source files.
Cause: Robocopy by default only copies data and attributes. /COPY:DAT (default) copies Data, Attributes, Timestamps. Some operations or switches override timestamp preservation.
Solution: Use explicit copy flags:
/COPY:DATfor basic copies (data, attributes, timestamps)/COPYALLfor complete copies including security descriptors- Verify
/DCOPY:DATis used for directory timestamps
Prevention: Always specify /COPY and /DCOPY options explicitly in scripts rather than relying on defaults. Test on small file sets and verify timestamps before large operations.
Robocopy Keeps Retrying Failed Network Path
Problem: Robocopy endlessly retries accessing a network path that's offline or doesn't exist, never completing the operation.
Cause: Default /R:1000000 retry count combined with /W:30 (30-second wait) causes operations to continue for years on persistent network failures.
Solution:
- Press Ctrl+C to stop immediately
- Verify network path is accessible:
dir \\server\share - Re-run with low retry count:
/R:1 /W:5to fail fast - Fix network connectivity or path before retrying
Prevention: Use /R:3 /W:10 or similar reasonable values in all scripts. This allows transient failures to be retried while preventing indefinite hangs on persistent problems.
Related Commands
xcopy – Extended Copy
Legacy file copy command with basic recursion and attribute preservation. Robocopy supersedes xcopy with better error handling, logging, and features, but xcopy remains available for backward compatibility.
When to use xcopy: For simple copies in legacy scripts or environments without Robocopy. Use Robocopy for any production file operations requiring reliability or advanced features.
copy – Basic File Copy
Windows' simplest file copy command. Copies individual files without recursion, attribute preservation, or error recovery. Appropriate only for single-file copies in simple scenarios.
When to use copy: For quick single-file copies in interactive sessions. Never use copy for production operations—Robocopy or xcopy provide essential error handling and logging.
PowerShell Copy-Item
PowerShell's object-oriented file copy cmdlet. Supports recursion and basic filtering but lacks Robocopy's advanced features like restartable transfers, detailed logging, and mirror mode.
When to use Copy-Item: Within PowerShell scripts requiring object pipeline integration. Use Robocopy for large-scale operations, network transfers, or when advanced logging is required.
File Explorer Copy
Windows GUI file copy. User-friendly but lacks scripting capability, advanced options, and detailed logging. Cannot preserve all NTFS attributes or handle long paths reliably.
When to use Explorer: For simple interactive copies where GUI convenience outweighs command-line power. Use Robocopy for automated operations or when preserving security descriptors.
rsync (via WSL)
Linux/Unix file synchronization tool available in Windows Subsystem for Linux. More flexible than Robocopy for complex synchronization scenarios but requires WSL installation.
When to use rsync: For cross-platform synchronization or when complex include/exclude patterns exceed Robocopy's capabilities. Use Robocopy for native Windows-to-Windows operations.
Frequently Asked Questions
What is the difference between robocopy and xcopy?
Robocopy is a modern replacement for xcopy with superior features: automatic retry logic, restartable transfers (/Z), comprehensive logging, multi-threaded copying, bandwidth throttling, and better NTFS attribute preservation. Robocopy verifies copies and handles network interruptions gracefully, while xcopy fails completely on network errors. Always prefer Robocopy for production operations.
Does robocopy overwrite files by default?
No, Robocopy's default behavior is to skip files that already exist in the destination with the same size and timestamp. Only newer or modified source files overwrite destination files. Use /IS to include identical files (force overwrite) or /XO to exclude older source files (never overwrite newer destination files).
How do I copy only new and modified files with robocopy?
Robocopy's default behavior copies only new and modified files automatically—no special switches needed. Simply use: robocopy source dest /E. Robocopy compares timestamps and sizes, skipping unchanged files. Add /XO to additionally skip files where destination is newer than source.
What does robocopy /MIR do?
The /MIR (mirror) switch creates an exact replica of source at destination by combining full directory copy (/E) with deletion of destination files/folders not present in source. ⚠️ WARNING: /MIR permanently deletes files! Use /L to preview operations first. Mirror mode is ideal for disaster recovery replicas but dangerous if misused.
Can robocopy copy files in use or locked?
Robocopy can copy most files in use that allow shared read access. Use /B (backup mode) to bypass security and copy locked system files (requires administrator privileges). For files exclusively locked (no shared access), Robocopy will retry based on /R:n settings but ultimately fail if the lock persists. Volume Shadow Copy Service (VSS) integration via third-party tools provides better handling of in-use files.
How do I use robocopy for incremental backups?
Use /MAXAGE:n to copy only files modified in the last n days: robocopy C:\Data D:\Backup /E /MAXAGE:1 /LOG+:backup.log copies files modified in the last 24 hours. For differential backups, use /M (copy files with archive attribute set, then clear it) or /A (copy archive-flagged files without clearing). Combine with date-stamped destination folders for retention management.
What are robocopy exit codes?
Exit codes indicate operation status: 0 = No files copied/no errors, 1 = Files copied successfully, 2 = Extra files in destination, 4 = Mismatches detected, 8 = Copy errors occurred, 16 = Serious error (no files copied). Codes can combine (e.g., 3 = 1+2 = successful copy + extras detected). In batch scripts, treat codes 0-7 as success, 8+ as errors requiring investigation.
How do I make robocopy faster?
Use multi-threading: /MT:16 or /MT:32 for dramatically faster performance on multi-core systems. Disable unnecessary features: /NP (no progress), /NDL (no directory list), /NFL (no file list) reduce overhead. Use /XO to skip older files. For SSDs, higher thread counts (/MT:32 or more) provide maximum performance. Remove /Z if network is reliable—restartable mode adds overhead.
Can robocopy verify copied files?
Robocopy doesn't have built-in hash verification, but it verifies file size after copying. For cryptographic verification, use /V (verify—deprecated and not recommended) or post-copy verification tools. Robocopy's reliability comes from retry logic and detailed logging rather than hash verification. For mission-critical copies requiring cryptographic verification, use specialized tools or hash comparison scripts after Robocopy completes.
How do I exclude files and folders with robocopy?
Use /XF for files: /XF *.tmp *.log (supports wildcards). Use /XD for directories: /XD "node_modules" ".git" "bin" (names or paths). Multiple exclusions are space-separated. Example: robocopy source dest /E /XF *.tmp /XD temp logs excludes all *.tmp files and "temp" and "logs" directories. Exclusions significantly improve performance by skipping unnecessary files.
What does robocopy /B do?
The /B switch enables backup mode, allowing Robocopy to bypass NTFS security and copy files regardless of ACL permissions. This requires administrator privileges and uses the "Backup Files and Directories" user right. Essential for copying system files, migrating user profiles, or copying files with restrictive permissions where normal access would be denied. Use /B /COPYALL to preserve security descriptors while bypassing restrictions.
Can robocopy resume interrupted transfers?
Yes, use /Z for restartable mode. When transfers are interrupted (network disconnect, system shutdown), re-running the same Robocopy command resumes from the interruption point rather than restarting. /Z adds overhead—only use it for unreliable networks or very large files. For reliable networks, default mode is faster and also resumes at the file level (completes full files, skips already-copied files).
Quick Reference Card
| Command Example | Purpose | Key Switches |
|---|---|---|
robocopy C:\Source D:\Dest /E | Copy directory tree | /E = subdirectories including empty |
robocopy C:\Source D:\Dest /MIR | Mirror (sync with delete) | /MIR = mirror, deletes from dest |
robocopy Source Dest /E /COPYALL /B | Copy with all NTFS attributes | /COPYALL = all attributes, /B = backup mode |
robocopy Source Dest /E /XF *.tmp /XD logs | Exclude files/folders | /XF = exclude files, /XD = exclude dirs |
robocopy Source Dest /E /MT:16 /LOG:log.txt | Fast multi-threaded copy | /MT = threads, /LOG = logging |
robocopy Source Dest /E /MAXAGE:1 | Copy files modified today | /MAXAGE:1 = last 1 day |
robocopy \\Server\Share C:\Local /E /Z | Network copy with resume | /Z = restartable mode |
Try Robocopy Concepts in Our Simulator
Want to understand file management concepts safely? Use our interactive Windows Command Simulator to explore command-line file operations without affecting real data. While production Robocopy operations require careful planning, our simulator provides a risk-free learning environment.
Explore our complete Windows Commands Reference for detailed documentation on 200+ CMD commands, including copy, xcopy, move, and other file management tools essential for Windows system administration.
Summary
The robocopy command (Robust File Copy) delivers enterprise-grade file copying capabilities essential for reliable data operations in Windows environments. Whether performing automated nightly backups with /MIR, migrating terabytes of data between file servers with /COPYALL preserving all NTFS attributes, or transferring large files over unreliable networks with /Z restartable mode, Robocopy provides the reliability, logging, and advanced features that basic copy commands cannot match.
Understanding Robocopy's powerful switches and their implications is critical for safe, effective use: /MIR creates exact mirrors by deleting destination files, /MT enables multi-threaded performance, /Z allows resumable transfers, /B bypasses security restrictions, and /COPYALL preserves complete NTFS metadata. Proper switch selection dramatically affects operation speed, data preservation, and risk of unintended deletion.
Key operational principles include always testing with /L before /MIR operations, using reasonable /R:n retry values to prevent indefinite hangs, specifying /LOG for troubleshooting and compliance, adjusting /MT thread counts for performance, and understanding exit codes for proper script error handling. For production environments, detailed logging, exit code checking, and thorough testing on representative datasets prevent catastrophic mistakes.
Most importantly, Robocopy excels in scenarios where reliability matters: automated backup solutions requiring verification and retry logic, large-scale migrations preserving security context, network transfers surviving interruptions, and enterprise file operations requiring comprehensive audit trails. Master Robocopy switches, understand interaction between options, and incorporate rigorous testing procedures into deployment workflows for robust, reliable Windows file operations.
Practice Robocopy on test directories first, document scripts thoroughly with clear switch explanations, maintain comprehensive logs for troubleshooting and compliance, and combine Robocopy with monitoring solutions for enterprise-grade file management automation.