System command

robocopy command

Copy directory trees with retry, mirroring and metadata options; mirroring can remove destination files.

Availability: Microsoft Learn command reference spanning Windows client and Windows Server releases; some entries are legacy, role-specific, optional-feature or interactive subcommands.中文

Documented syntax

robocopy <source> <destination> [<file>[ ...]] [<options>]

The linked Microsoft Learn article is the upstream authority. Availability may depend on Windows release, role, optional feature or interactive tool context.

Examples

Example usage for robocopy.

robocopy C:\data D:\backup /E /R:2 /W:2

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy c:\reports "\\marketing\videos" yearly-report.mov /mt /z

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy C:\Users\Admin\Records D:\Backup /E /ZB /LOG:C:\Logs\Backup.log

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy C:\Users\Admin\Records D:\Backup /MIR /R:2 /W:5 /LOG:C:\Logs\Backup.log

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy C:\Users\Admin\Records D:\Backup /S /MAXAGE:7 /MOV /LOG:C:\Logs\Backup.log

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy C:\Users\Admin\Records D:\Backup /ETA /PURGE /LOG:C:\Logs\Backup.log

Example from the linked Microsoft Learn article. Check its paths, targets and availability before adapting it.

robocopy C:\Users\Admin\Records D:\Backup /S /E /COPY:DAT /MT:16 /LOG:C:\Logs\Backup.log

Parameters, options and clauses

Option / clauseDescription
/S, /ECopy subdirectories; /E includes empty directories.
/MIRMirror a tree; may delete destination files absent from the source.
/COPY:<flags>Choose file properties to copy, such as data, attributes and timestamps.
/R:<n>, /W:<n>Set retry count and wait time after a failed copy.
/LList planned actions without copying or deleting files.
/MT[:n]Use multiple threads where supported.
/lev:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/zMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/bMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/zbMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/jMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/efsrawMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/copy:<copyflags>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/dcopy:<copyflags>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/secMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/copyallMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nocopyMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/secfixMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/timfixMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/a-:[RASHCNETO]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/createMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/fatMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/256Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/mon:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/mot:<m>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/rh:hhmm-hhmmMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/pfMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/ipg:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/sjMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/slMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/sparse:<yMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nocloneMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/iomaxsize:<n>[kmg]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/iorate:<n>[kmg]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/threshold:<n>[kmg]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xa:[RASHCNETO]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xf <filename>[ ...]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xd <directory>[ ...]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xcMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/maxage:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/minage:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/maxlad:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/minlad:<n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xjMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/fftMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/regMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/tbdMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/vMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/tsMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/fpMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/bytesMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nsMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/ncMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nflMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/ndlMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/npMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/etaMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/log:<logfile>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/log+:<logfile>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/unilog:<logfile>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/unilog+:<logfile>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/teeMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/njhMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/njsMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/unicodeMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/job:<jobname>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/save:<jobname>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/quitMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/purgeMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/movMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/moveMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/a+:[RASHCNET]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nodcopyMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nooffloadMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/compressMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/sparse:<y|n>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/aMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/mMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/ia:[RASHCNETO]Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xnMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xoMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xxMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xlMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/dstMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xjdMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xjfMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nosdMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/noddMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/ifMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
<source>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<destination>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<file>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
<options>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory