Robocopy is a command-line file transfer utility for Windows. It is functionally more comprehensive than the <code>COPY</code> and <code>XCOPY</code> commands, but replaces neither. Created by Kevin Allen and first released as part of the Windows NT 4.0 Resource Kit, it has been a standard feature of Windows since Windows Vista and Windows Server 2008.
Robocopy provides features not in the and commands, including:
Robocopy syntax is markedly different from its predecessors, copy and xcopy, in that it accepts only folder names, without trailing backslash, as its source and destination arguments. File names and wildcard characters (such as <code>*</code> and <code>?</code>) are not valid as source or destination arguments. Files may be selected or excluded using the optional file filtering argument (which supports wildcards) along with various other options. The files named are copied only from the folder selected for copying. Fully qualified path names are not supported.
Per normal operation in Windows, command name matching is case insensitive, if more than one option is specified, they must be separated by whitespace and if a directory name contains a special character, such as whitespace, it must be enclosed in double quotes.
Robocopy reports the name of each directory encountered, in alphabetical order. Each name is preceded by the number of files in the directory that fulfill the criteria for being copied. If the directory does not yet exist in the target, it is marked "New Dir"; if the directory is empty and the /E option is not used, or it contains no files meeting the criteria, a new directory will not be created. If the /NFL (no file names in log) option is not used, the files being copied will be listed after the name of the directory they are in. At the end of the output is a table giving numbers of directories, files, and bytes. For each of these, the table gives the total number found in the source, the number copied (including directories marked "New Dir" even if they are not copied), the number skipped (because they already exist in the target), and the number of mismatches, FAILED, and extras. "Failed" can mean that there was an I/O error that prevented a file being copied, or that access was denied. There is also a row of time taken (in which the time spent on failed files seems to be in the wrong column).
The inter-packet gap (IPG) option allows some control over the network bandwidth. In theory, the following formula expresses the delay (, in milliseconds) required to simulate a desired bandwidth (, in kilobits per second), over a network link with an available bandwidth of kbps:
In practice however, experimentation is usually required to find a suitable delay, due to factors such as the nature and volume of other traffic on the network. The methodology employed by the IPG option may not offer the same level of control provided by some other bandwidth throttling technologies, such as BITS (which is used by Windows Update and BranchCache).
A process can lock a file for exclusive read access. Normally, the volume shadow copy service is used for such situations, but Robocopy does not use it. Consequently, Robocopy is not suitable for backing up a live volume. However, utilities such as ShadowSpawn or DiskShadow (included with Windows Server 2008), can be used beforehand to create a shadow copy of a given volume, which Robocopy can then backup.
They ignore changed security attributes of previously mirrored files.
When specifying the <code>/MT[:n]</code> option to enable multithreaded copying, the <code>/NP</code> option to disable reporting of the progress percentage for files is ignored. By default the MT switch provides 8 threads. The n is the number of threads you specify if you do not want to use the default.
A long-standing issue with Robocopy is that if you backup from the root folder of a drive [ e.g., ], the destination files will be given attributes including SH. This means that they will be invisible to normal access (including DIR in cmd.exe). To fix this, add to the robocopy command line - or do an ATTRIB command to remove them afterwards.
The following copies two files from folder <code>c:\bar</code> to <code>c:\baz</code>:
To copy all PDF files from <code>c:\bar</code> to <code>c:\baz</code>:
The following copies directory contents of to including file data, attributes and timestamps, recursively with empty directories (<code>/E</code>):
The following copies directory recursively (<code>/E</code>), copies file information (<code>/COPYALL</code>, equivalent to <code>/COPY:DATSOU</code>, <code>D</code>=Data, <code>A</code>=Attributes, <code>T</code>=Timestamps, <code>S</code>=Security=NTFS ACLs, <code>O</code>=Owner info, <code>U</code>=Auditing info), does not retry locked files (<code>/R:0</code>) (the number of retries on failed copies default value is 1 million), preserves original directories' Timestamps (<code>/DCOPY:T</code> - requires version XP026 or later):
The following mirrors A to B, destroying any files in B that are not present in A (<code>/MIR</code>). It copies in resume mode (<code>/Z</code>) in case the network connection is lost:
Although Robocopy is a command-line tool, Microsoft TechNet provided a GUI front-end called Robocopy GUI. It was developed by Derk Benisch, a systems engineer with the MSN Search group at Microsoft, and required .NET Framework 2.0. It included a copy of Robocopy version XP026. It is no longer available from Microsoft, but may be downloaded from the Internet Archive's Wayback Machine.
All versions of Robocopy store their version number and release date in their executable file header, viewable with File Explorer or PowerShell. Some versions report their version number in feedback output.