Robocopy Explained

Robocopy
Other Names:Robust File Copy for Windows
Developer:Microsoft
Operating System:Windows NT 4 and later
Included With:Windows Vista and later
Genre:Command
License:Freeware

Robocopy is a command-line file transfer utility for Windows. It is functionally more comprehensive than the [[copy (command)|COPY]] and [[XCOPY]] commands, but replaces neither. Created by Kevin Allen[1] 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.

Features

Robocopy provides features not in the and commands, including:

Use

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 * and ?) 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.[9] 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.[10]

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).

Bandwidth throttling

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:

D={BA-BD\overBA x BD} x 512 x 1000

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).

Limitations

Does not copy open filesA process can lock a file for exclusive read access.[11] 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[12] or DiskShadow[13] (included with Windows Server 2008), can be used beforehand to create a shadow copy of a given volume, which Robocopy can then backup.
Versions on systems older than Windows Vista do not mirror properlyThey ignore changed security attributes of previously mirrored files.[14] [15]
Multithreaded progressWhen specifying the /MT[:n] 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.[16]
Backup of rootA long-standing issue with Robocopy is that if you backup from the root folder of a drive [e.g., {{code|robocopy d:\ b:\d-backup\ ....}}], 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.

Examples

The following copies two files from folder c:\bar to c:\baz:

>robocopy c:\bar c:\baz file1.txt file2.db

To copy all PDF files from c:\bar to c:\baz:

>robocopy c:\bar c:\baz *.pdf

The following copies directory contents of to including file data, attributes and timestamps, recursively with empty directories (/E):

>robocopy "C:\Directory A" "C:\Directory B" /E

The following copies directory recursively (/E), copies file information (/COPYALL, equivalent to /COPY:DATSOU, D=Data, A=Attributes, T=Timestamps, S=Security=NTFS ACLs, O=Owner info, U=Auditing info), does not retry locked files (/R:0) (the number of retries on failed copies default value is 1 million), preserves original directories' Timestamps (/DCOPY:T - requires version XP026 or later):

>robocopy C:\A C:\B /COPYALL /E /R:0 /DCOPY:T

The following mirrors A to B, destroying any files in B that are not present in A (/MIR). It copies in resume mode (/Z) in case the network connection is lost:

>robocopy C:\A \\backupserver\B /MIR /Z

GUI

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.[17] 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.[18]

Versions

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.

Product version File version Year Bundled with
1.541996 Windows NT 4.0 Resource Kit
1.701997 Windows NT Resource Kit
1.714.0.1.71 1997 Windows NT Resource Kit
1.954.0.1.95 1999 Windows 2000 Resource Kit
1.964.0.1.96 1999 Windows 2000 Resource Kit
XP0105.1.1.1010 2003 Windows 2003 Resource Kit
XP0265.1.2600.26 2005 Robocopy GUI v.3.1.2
XP0275.1.10.1027 2008 Windows Vista, Server 2008, 7, 2008 R2
6.16.1.7601 2009 KB2639043
Windows 8 and later, Windows Server 2012 and later

See also

External links

Notes and References

  1. Web site: AMA with Dave Plummer, creator of Task Manager . Reddit.com . 18 December 2020. 19 December 2020.
  2. Web site: Robocopy.exe - Robust File Copy Utility - Version XP010 . . 2003 . Backup mode copies [...] enable you to copy some files as a Backup Operator that you would not be able to copy as a normal user. .
  3. Web site: Default groups . 6 June 2011 . Microsoft . Backup Operators [...] Members of this group can back up and restore all files [...], regardless of their own individual permissions on those files. .
  4. Web site: Robocopy XP010 FAQ. Lewis. Dick. 15 November 2004. Windows IT Pro. Penton Media. 2. https://web.archive.org/web/20121009110523/http://www.windowsitpro.com/content1/topic/robocopy-xp010-faq/catpath/migration/page/2. 9 October 2012. dead.
  5. Web site: Return codes that are used by the Robocopy utility in Windows Server 2008 or Windows Server 2008 R2 . Windows Server troubleshooting . . . 23 February 2023 . Han . Liang . Lucy . Zou . Simonx . Xu.
  6. Web site: Holliday . Grant . Multi-threaded robocopy for faster copies . Grant Holliday's Blog . . https://web.archive.org/web/20180813013804/https://blogs.msdn.microsoft.com/granth/2009/12/07/multi-threaded-robocopy-for-faster-copies/ . 13 August 2018 . 7 December 2009 . dead.
  7. Web site: RoboCopy supports Copying Files over SMB with Compression on Windows Server 2019, and beyond . Sander . Berkouwer . dirteam.com . 7 September 2020. 14 February 2021 .
  8. Web site: SMB Compression Lowers Bandwidth and Improves Copy Times in Windows Server and Azure. Smith . Russell . Petri . 27 November 2020 .
  9. Web site: Robocopy . Microsoft Docs . . 14 January 2019 . 31 October 2016.
  10. Web site: Robocopy . Microsoft Technet . 7 June 2020.
  11. Web site: CreateFile function . Windows App Development . 9 February 2023 . . Microsoft . FILE_SHARE_READ [...] Enables subsequent open operations on a file or device to request read access. Otherwise, other processes cannot open the file or device if they request read access..
  12. Web site: ShadowSpawn . Craig Andera . ShadowSpawn.exe is an open source MIT licensed tool that creates and manages shadow copies. . 2015-07-14.
  13. Web site: Diskshadow . 18 April 2012 . Microsoft TechNet . DiskShadow.exe is a tool that exposes the functionality offered by the Volume Shadow Copy Service (VSS). . 2013-03-06.
  14. Web site: Microsoft's Robocopy compromise. 2008-08-04. ZDNet. https://web.archive.org/web/20100317020028/http://www.zdnet.com.au/blogs/snorage/soa/Microsoft-s-Robocopy-compromise/0,2000064373,339291041,00.htm. March 17, 2010. dead. 2012-11-11.
  15. Web site: Ugly bug in Robocopy - ignoring security on file level - Martin Zugec blog. 2008-03-03. Msmvps.com. 2012-11-11. 2009-05-08. https://web.archive.org/web/20090508142211/http://msmvps.com/blogs/martinzugec/archive/2008/03/03/ugly-bug-in-robocopy-ignoring-security-on-file-level.aspx. dead.
  16. Web site: Robocopy's /MT option disables /NP option. 2009-12-13. Microsoft TechNet. 2014-02-26.
  17. News: Joshua Hoffman. Utility Spotlight Robocopy GUI. TechNet Magazine. Microsoft Corporation and CMP Media, LLC. November 2006. 2008-07-17 .
  18. Web site: Is Microsoft's Robocopy GUI still available . Windows TenForums . 2 May 2022.