Robocopy
Robocopy, or "Robust File Copy", is a command-line directory and/or file replication command for Microsoft Windows. Robocopy functionally replaces Xcopy, with more options. 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. The command is robocopy.
Features
Robocopy is noted for capabilities above and beyond the built-in Windows copy and xcopy commands, including the following, some requiring appropriate command-line options:- Ability to tolerate network interruptions and resume copy.
- Ability to skip NTFS junction points which can cause copying failures because of infinite loops
- Ability to copy file data and attributes correctly, and to preserve original timestamps, as well as NTFS ACLs, owner information, and audit information using the
/COPYALL
or/COPY:
command line switches. - Beginning with the XP026 version, the ability to copy folder date and timestamps, even with the ability to update folder timestamps on folders already created from previous versions.
- Ability to assert the Windows NT "backup right" so an administrator may copy an entire directory, including files denied readability to the administrator.
- Persistence by default, with a programmable number of automatic retries if a file cannot be copied.
- A "mirror" mode, which keeps trees synchronised by also deleting files in the destination that are not present in the source.
- Ability to skip files already in the destination folder with identical size and timestamp.
- A continuously updated command-line progress indicator.
- Ability to copy paths exceeding 259 characters — up to a theoretical limit of about 32,000 characters — without errors.
- Multithreaded copying introduced with Windows 7 and Windows Server 2008 R2.
- Return code on program termination for batch file usage.
Examples of use
- Copy directory contents of the source to the destination , recursively with empty directories :
- Copy directory recursively, copy all file information, do not retry locked files , preserve original directories' Timestamps :
- Mirror A to B, destroying any files in B that are not present in A, copy files in resume mode in case network connection is lost:
Syntactic focus on copying folders
Robocopy syntax is markedly different from its predecessors, in that it accepts only folder names, without trailing backslash, as its source and destination arguments. File names and wildcard characters are not valid as source or destination arguments; files may be selected or excluded using the optional "file" filtering argument along with various other options.For example, to copy two files from folder
c:\bar
to c:\baz
, the following syntax is used:robocopy c:\bar c:\baz file1.txt file2.db
And to copy all PDF files from
c:\bar
to c:\baz
:robocopy c:\bar c:\baz *.pdf
The files named are copied only from the folder selected for copying; fully qualified path names are not supported.
Output
Robocopy outputs to the screen, or optionally to a log file, all the directories it encounters, in alphabetical order. Each directory is preceded by the number of files in that directory that fulfill the criteria for being copied. If the directory does not yet exist in the target, it is marked "New Dir". But 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 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", the number "skipped", 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.
Bandwidth throttling
Robocopy's "inter-packet gap" option allows some control over the network bandwidth used in a session. In theory, the following formula expresses the delay required to simulate a desired bandwidth, over a network link with an available bandwidth of BA kbps:In practice however, some 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.
Limitations
- Robocopy does not copy open files. Any process may open files for exclusive read access by withholding the
FILE_SHARE_READ
flag during opening. Even Robocopy's Backup mode will not touch those files.. Normally Volume Shadow Copy Service is used for such situations, but Robocopy does not use it. Consequently, Robocopy is not suitable for backing up live operating system volumes. However, a separate utility such asShadowSpawn
orGSCopyPro
orDiskShadow.exe
, can be used beforehand to create a shadow copy of a given volume, which Robocopy can then back up. - Robocopy versions on systems older than Windows Vista do not mirror properly. They ignore changed security attributes of previously mirrored files.
- When specifying the
/MT
option to enable multithreaded copying, the/NP
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.GUI
There are other non-Microsoft GUIs for Robocopy:
- "WinRoboCopy" revision 1.3.5953.40896 released on April 19, 2016.
- "Easy RoboCopy" latest version 1.0.15 released on January 8, 2018.
- A program by SH-Soft, also called "Robocopy GUI" v1.0.0.24.
- v1.0.0.4
Versions
Several versions of Robocopy do not report the version number when executingrobocopy /?
on the command line. However, their version is stored inside the executable itself and can be queried with PowerShell for example or inside Windows Explorer by right-clicking on Robocopy.exe, selecting Properties, then clicking on the Details tab.Product version | File version | Year | Origin | Other |
1.54 | - | 1996 | Windows NT 4.0 Resource Kit | © 1996 |
1.70 | - | 1997 | Windows NT Resource Kit | |
1.71 | 4.0.1.71 | 1997 | Windows NT Resource Kit | |
1.95 | 4.0.1.95 | 1999 | Windows 2000 Resource Kit | |
1.96 | 4.0.1.96 | 1999 | Windows 2000 Resource Kit | © 1995-1997 |
XP010 | 5.1.1.1010 | 2003 | Windows 2003 Resource Kit | |
XP026 | 5.1.2600.26 | 2005 | Downloaded with Robocopy GUI v.3.1.2; /DCOPY:T option introduced | |
XP027 | 5.1.10.1027 | 2008 | Bundled with Windows Vista, Server 2008, Windows 7, Server 2008r2 | © 1995-2004 |
6.1 | 6.1.7601 | 2009 | © 2009 | |
6.2 | 6.2.9200 | 2012 | Bundled with Windows 8 | © 2012 |
6.3 | 6.3.9600 | 2013 | Bundled with Windows 8.1 | © 2013 |
10.0 | 10.0.10240.16384 | 2015 | Bundled with Windows 10 | © 2015 |
10.0.16299 | 10.0.16299.15 | 2017 | Bundled with Windows 10 1709 | © 2017 |
10.0.17134 | 10.0.17134.1 | 2018 | Bundled with Windows 10 1803 | © 2018 |
10.0.17763 | 10.0.17763.1 | 2018 | Bundled with Windows 10 1809 | © 2018 |
10.0.18362 | 10.0.18362.1 | 2019 | Bundled with Windows 10 1903 | © 2019 |