Jump to content

Robocopy: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Return codes are present in the current version
Line 31: Line 31:


==Common usage scenarios==
==Common usage scenarios==
Copy directory contents of {{code|foo}} to {{code|bar}} (including file data, attributes and timestamps), recursively with empty directories (/E):
Copy directory contents of {{code|A}} to {{code|B}} (including file data, attributes and timestamps), recursively with empty directories (/E):
Robocopy C:\foo C:\bar /E
Robocopy C:\A C:\B /E
Copy directory recursively (/E), and copy all file information (/COPYALL, equivalent to /COPY:DATSOU, D=Data, A=Attributes, T=Timestamps, S=Security=[[NTFS]] [[Access control list|ACL]]s, O=Owner info, U=aUditing info), do not retry locked files (/R:0)(the number of retries on failed copies default value is 1 million), preserve original directories' Timestamps (/DCOPY:T - requires version XP026 or later):
Copy directory recursively (/E), and copy all file information (/COPYALL, equivalent to /COPY:DATSOU, D=Data, A=Attributes, T=Timestamps, S=Security=[[NTFS]] [[Access control list|ACL]]s, O=Owner info, U=aUditing info), do not retry locked files (/R:0)(the number of retries on failed copies default value is 1 million), preserve original directories' Timestamps (/DCOPY:T - requires version XP026 or later):
Robocopy C:\foo C:\bar /COPYALL /E /R:0 /DCOPY:T
Robocopy C:\A C:\B /COPYALL /E /R:0 /DCOPY:T
Mirror foo to bar, destroying any files in bar that are not present in foo (/MIR), copy files in restartable mode (/Z) in case network connection is lost:
Mirror A to B, destroying any files in bar that are not present in foo (/MIR), copy files in restartable mode (/Z) in case network connection is lost:
Robocopy C:\foo \\backupserver\bar /MIR /Z
Robocopy C:\A \\backupserver\B /MIR /Z


==Folder copier, not file copier==
==Folder copier, not file copier==

Revision as of 16:40, 3 March 2011

Robocopy
Developer(s)Microsoft
Stable release
XP027
Operating systemWindows NT, Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008
LicenseProprietary

Robocopy, or "Robust File Copy", is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was introduced as a standard feature of Windows Vista, Windows 7 and Windows Server 2008. The command is literally Robocopy; use Robocopy /? for information on how to use.

Features

Robocopy is notable for capabilities above and beyond the built-in Windows copy and xcopy commands, including the following:

  • Ability to tolerate network interruptions and resume copying. (incomplete files are marked with a date stamp of 1980-01-01 and contain a recovery record so Robocopy knows where to continue from)
  • Ability to copy file data and attributes correctly, and to preserve original timestamps, as well as NTFS ACLs, owner information, and audit information using command line switches. (/COPYALL or /COPY:) Copying folder timestamps is also possible in later versions (/DCOPY:T).
  • Ability to assert the Windows NT "backup right" (/B) 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 opened.
  • A "mirror" mode, which keeps trees in sync by optionally deleting files out of the destination that are no longer present in the source.
  • Ability to skip files that already appear in the destination folder with identical size and timestamp.
  • Ability to copy large numbers of files that would crash the built-in XCOPY utility.[citation needed]
  • A continuously-updated command-line progress indicator.
  • Ability to copy file and folder names exceeding 256 characters — up to a theoretical limit of 32,000 characters — without errors.[1]
  • Multithreaded copying. (Windows 7 only) [2]
  • Return code[3] on program termination for batch file usage.

Notably, Robocopy will fail to copy open files. The so-called Backup mode is sometimes mistaken as an ability to copy open files, which it is not. Backup mode is an administrative privilege that allows Robocopy to override permissions settings (specifically, NTFS ACLs) for the purpose of making backups. The Windows Volume Shadow Copy service is the only Windows subsystem that can copy open files, which it does by snapshotting them for point-in-time consistency. Robocopy does not implement accessing the Volume Shadow Copy service in any way, inhibiting its usefulness as a backup utility for volumes that may be in use. However, one can use separate utilities such as VSHADOW or DISKSHADOW (included with Windows Server 2008) to create a shadow copy of a given volume which Robocopy can back up.

On the other hand, by design, the original Robocopy version is not able to replicate security attributes of files which have had their security permissions changed after an initial mirroring.[4] This behavior was changed on Robocopy versions included in Windows 2008 and Windows Vista. The downside of this is that Robocopy does not behave consistently between platforms.[5]

Common usage scenarios

Copy directory contents of A to B (including file data, attributes and timestamps), recursively with empty directories (/E):

 Robocopy C:\A C:\B /E

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

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

Mirror A to B, destroying any files in bar that are not present in foo (/MIR), copy files in restartable mode (/Z) in case network connection is lost:

 Robocopy C:\A \\backupserver\B /MIR /Z

Folder copier, not file copier

Robocopy syntax is markedly different from standard copy commands, as it accepts only folder names as its source and destination arguments. File names and wild-card characters (such as "*.*") are not valid source or destination arguments. Files may be selected or excluded using the optional filespec filtering argument. Filespecs can only refer to the filenames relative to the folders already selected for copying. Fully qualified path names are not supported.

For example, in order to copy the file foo.txt from directory c:\bar to c:\baz, one could use the following syntax:

 Robocopy c:\bar c:\baz foo.txt

Bandwidth throttling

Robocopy's "inter-packet gap" (IPG) option allows some control over the network bandwidth utilized in a session. In theory, the following formula expresses the delay (D, in milliseconds) required to simulate a desired bandwidth (BD, in kilobits per second), 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 (which is utilized by Windows Update and BranchCache).


GUI front-end

Although Robocopy itself is a command-line tool, Microsoft Technet has provided a GUI front-end. The GUI requires the installation of the .NET Framework 2.0 (40 Mb), if it is not already installed. It was developed by Derk Benisch, a systems engineer with the MSN Search group at Microsoft.[6] The Microsoft Robocopy GUI also includes version XP026 of Robocopy (Vista version). When downloaded from the TechNet link below, the version reported is "Microsoft Robocopy GUI 3.1.2."

There are other non-Microsoft GUIs for Robocopy. The most popular among them appears to be a program by SH-Soft, confusingly also called "Robocopy GUI" [7].

A copying program with a GUI, RichCopy, is also available on Microsoft's Technet. While it is not based on Robocopy, it offers similar features, and it does not require the installation of the .NET 2.0 framework. [8]

Versions

Product version File version Year Origin Other
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 (c) 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
XP027 5.1.10.1027 2008 Bundled with Windows Vista, Server 2008 and later (c) 1995-2004

See also

References

  1. ^ http://windowsitpro.com/Windows/Articles/ArticleID/44324/pg/2/2.html Robocopy XP010 FAQ Wield powerful new switch options.
  2. ^ http://technet.microsoft.com/en-us/magazine/dd542631.aspx
  3. ^ http://support.microsoft.com/kb/954404/en-us Robocopy Return Codes
  4. ^ Microsoft's Robocopy compromise.
  5. ^ Ugly bug in Robocopy - ignoring security on file level.
  6. ^ Joshua Hoffman (November, 2006). "Utility Spotlight Robocopy GUI". TechNet Magazine. Microsoft Corporation and CMP Media, LLC. Retrieved 2008-07-17. {{cite news}}: Check date values in: |date= (help); Cite has empty unknown parameter: |coauthors= (help)
  7. ^ http://www.sh-soft.com/front_content.php?idcat=7 SH-Soft Tools: Robocopy GUI
  8. ^ "Free Utility: RichCopy, an Advanced Alternative to RoboCopy". TechNet Magazine. Microsoft Corporation and CMP Media, LLC. November, 2006. Retrieved 2008-07-17. {{cite news}}: Check date values in: |date= (help); Cite has empty unknown parameter: |coauthors= (help)