Robocopy reference for copying, migrations, ACLs, restartability, performance, filters, logs, dry runs and exit-code interpretation.
Core examples
- Recursive copy — robocopy C:\Source D:\Destination /ECopies subfolders including empty ones without deleting destination extras.
- Dry run — robocopy C:\Source D:\Destination /E /LShows what would happen without copying.
- Logging — robocopy C:\Source D:\Destination /E /TEE /LOG:C:\Logs\robocopy.logTEE writes to console and log.
- Restartable network copy — robocopy C:\Source \\Serveur\Partage /E /Z /R:2 /W:5/Z supports restartability but can affect performance.
Directory selection
- /E — Inclut sous-dossiers videsIncludes empty subdirectories without purging extras.
- /S — Sous-dossiers non videsAlternative when empty directories are not needed.
- /XD — Exclure dossiersExample: /XD "System Volume Information" Temp.
- /XJ — Exclure jonctionsAvoids some loops/unwanted junction traversal.
File selection
- /XF — Exclure fichiersAccepts names and patterns such as *.tmp.
- /MAX — Taille maximale en octetsUseful to exclude very large files in an initial pass.
- /MINAGE — Exclude files newer than the specified age or date. Check date/age syntax before production.
- /MAXAGE — Exclude files older than the specified age or date. Useful for archive scopes.
Data, attributes & ACLs
- /COPY:DAT — Data, Attributes, TimestampsTypical content copy without NTFS security.
- /COPY:DATSOU — Data, Attributes, Timestamps, Security, Owner, aUditingRequires sufficient privileges for S/O/U.
- /COPYALL — Equivalent to /COPY:DATSOU. Use only when full security preservation is required.
- /DCOPY:DAT — Directory data, attributes and timestamps. Useful when directory timestamps/attributes must be preserved.
Restartability & errors
- /Z — Restartable mode. Allows restart of interrupted large-file copies.
- /ZB — Restartable mode, falling back to backup mode. Backup mode requires privileges and can bypass some ACL restrictions.
- /R:n — Nombre de retriesSet a reasonable value; historical defaults can be very high.
- /W:n — Attente entre retriesLimits time wasted on persistently locked files.
Performance
- /MT:n — Copie multithreadExample /MT:16; increases CPU, disk and network load.
- /J — Unbuffered I/O. Can help with very large files depending on storage.
- /IPG:n — Inter-packet gapLegacy throttling approach; validate actual impact.
- Migration window — Measure throughput, IOPS and files per second. Small-file count can matter more than total bytes.
Mirror, purge & move
- /MIR — /E + /PURGECan delete destination content not present in source.
- /PURGE — Deletes extra files and directories at the destination. Always dry-run with /L on sensitive scopes.
- /MOVE — Moves files and directories. Deletes source after copying; destructive action.
- /MOV — Moves files only. Source directories remain.
Logs & exit codes
- /LOG — Write a log. Prefer a reliable local log path during critical migrations.
- /TEE — Console + logUseful for live monitoring and evidence.
- 0 to 7 — Robocopy result without a fatal copy failure. These codes represent copy/extra/mismatch combinations, not necessarily failure.
- >= 8 — Au moins une erreur de copieTreat as failure and inspect the log.
Key points
- Before /MIR, /PURGE, /MOVE or /MOV, run a /L dry-run and keep logs.
- /COPYALL and /ZB require appropriate privileges and can alter destination security.
- A Robocopy exit code below 8 is not necessarily failure.
- For migrations, compare file count, total size, ACLs and restored samples.