-->

Rabu, 03 Mei 2017

Robocopy, or "Robust File Copy", is a command-line directory and/or file replication command. Robocopy functionally replaces Xcopy, with more options. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in 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:

  • Ability to tolerate network interruptions and resume copying. (incomplete files are marked with a date stamp of 1970-01-01 and contain a recovery record so Robocopy knows where to continue from)
  • Ability to skip NTFS junction points which can cause copying failures because of infinite loops (/XJ)
  • 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.
  • 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. (Windows 7 and Windows Server 2008 R2)
  • Return code on program termination for batch file usage.

Limitations

No open files

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. (Backup mode instead runs Robocopy as a "Backup Operator". This allows Robocopy to override permissions settings, specifically, NTFS ACLs). Normally Volume Shadow Copy Service is used for such situations, but Robocopy does not use it. Therefore, Robocopy is not useful for backing up live operating system volumes. However, one can use a separate utility, such as ShadowSpawn (Free, Open Sourced, and MIT Licensed) or GSCopyPro ($30 - $50) or DiskShadow.exe (included with Windows Server 2008), to create a shadow copy of a given volume, which Robocopy can then be directed to back up.

XP mirroring bug

Robocopy versions on systems older than Windows Vista do not mirror properly. They ignore changed security attributes of previously mirrored files.

Multithread Copy/No Progress Bar

When 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 amount of threads you specify if you do not want to use the default.

Wildcarding treatment

The /XF switch does not work if given both a directory and a wildcard. For example, /XF pictures\*.jpg generates an error.

Common usage scenarios

Here are some examples of usage. If more than one option is specified, they must be separated by spaces.

  • Copy directory contents of Directory_A to Directory_B (including file data, attributes and timestamps), recursively with empty directories (/E):
Robocopy C:\Directory_A C:\Directory_B /E
  • Copy directory recursively (/E), 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 B that are not present in A (/MIR), copy files in resume mode (/Z) in case network connection is lost:
Robocopy C:\A \\backupserver\B /MIR /Z

If directory names have "funny" characters (like a space), they can be put in double quotes (as usual in command-line commands).

For the full reference, see the Microsoft TechNet Robocopy page.

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 refer only 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  

Output

By default 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 should not actually 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" (but this includes 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

Robocopy's "inter-packet gap" (IPG) option allows some control over the network bandwidth used 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:

D = B A âˆ' B D B A × B D × 512 × 1000 {\displaystyle D={B_{A}-B_{D} \over B_{A}\times B_{D}}\times 512\times 1000}

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 used by Windows Update and BranchCache).

GUI

Although Robocopy itself is a command-line tool, Microsoft TechNet provides 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 includes a copy of Robocopy version XP026.

There are other non-Microsoft GUIs for Robocopy:

  • "WinRoboCopy" revision 1.3.5953.40896 released on Apr 19, 2016.
  • "Easy RoboCopy" latest version 1.0.13 released in January 11, 2012.
  • A program by SH-Soft, also called "Robocopy GUI" v1.0.0.24 (October 8, 2005).
  • Cinchoo EazyCopy v1.0.0.4

Ken Tamaru of Microsoft has also developed a copying program similar to Robocopy, called RichCopy, which is available on Microsoft TechNet. While it is not based on Robocopy, it offers similar features, and it does not require .NET Framework.

Versions

Note: Several versions of Robocopy do not show the version number when executing Robocopy /? on the command line.

See also

  • List of file copying software
  • Command line
    • List of DOS commands
    • copy (command)
    • XCOPY
    • rsync
  • GUI
    • GS RichCopy 360
    • SyncToy
    • RichCopy
    • Ultracopier

References

External links

  • Official sources
    • Robocopy download (Version XP010) as part of Windows Server 2003 Resource Kit Tools. Includes 35-page documentation "robocopy.doc".
    • Robocopy short documentation on Microsoft TechNet Library
    • Robocopy GUI download (Version 3.1.2.0) on Microsoft TechNet Magazine
  • Other
    • ROBOCOPY.exe (XP Resource Kit/Standard Vista command)
 
Sponsored Links