Robocopy

From Wikipedia, the free encyclopedia

Robocopy, or "Robust File Copy" as it calls itself, is a command-line file copying tool introduced as a standard feature of Windows Vista, but which beforehand has always been available with the Windows Resource Kit, free to licensed users of Windows. Robocopy is designed for reliable copy or mirroring of entire folders of any size ensuring all NTFS attributes and properties are copied (except security-related ones unless specifically requested), particularly over network connections that are subject to disruption or outages. Robocopy's default settings are geared for this purpose, whereas other built-in utilities such as XCOPY require numerous command line switches in order to get this behavior. Copying of security information is supported, but isn't default and requires an explicit /COPYALL switch.

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

  • Ability to copy entire subdirectories (note: XCOPY can do this, COPY can't)
  • Ability to tolerate network outages and resume copying where it previously left off (incomplete files are noted with a date stamp of 1/1/1980 and contain a recovery record so Robocopy knows where to continue)
  • Ability to correctly copy NTFS ACLs, attributes, owner information, alternate data streams, auditing information, and timestamps by default, without the need for numerous oft-forgotten command line switches
  • 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 copy large quantities of files that would normally crash the built-in XCOPY utility.
  • A progress indicator on the command line that updates continuously

Although Robocopy itself is a command-line tool, there is a GUI front-end to Robocopy. [1]

Contents

[edit] Folder copier, not file copier

The syntax of Robocopy is markedly different from that of standard copy commands, in that it only accepts the names of folders, not files, as its source and destination arguments. Names of files and wildcard designations (such as "*.*") are not acceptable as source or destination, with one exception - Robocopy accepts a list of files or filespecs as optional filtering argument(s) after the source and destination. The filespecs can only refer to the filenames relative to the folders already selected for copying; fully-qualified pathnames are not accepted here.

[edit] Command line switches

  • /S copies subdirectories unless they're empty (like XCOPY)
  • /E copies subdirectories, even empty ones (like XCOPY)
  • /MIR activates mirror mode, deleting any files in the destination that aren't present in the source
  • /MOV moves the files, removing them from the source folder. /MOVE removes the source folder as well if empty.
  • /Z copy files in restartable mode. This is very useful for copying large files or many files over a unreliable network.
  • /COPYALL makes sure NTFS security information is copied
  • /XF filespec - excludes files indicated by filespec. Wildcards are accepted. Example: /XF *.bak will skip copying any file with an extension of .bak
  • /XJ - exclude junctions. When copying user accounts to another place in Windows Vista, it's important to exclude junctions. There is a junction in '\Users\...\AppData\Local' named 'Application Data' which points to its parent folder, creating a loop which will break Robocopy.
  • /R:n tells Robocopy to retry 'n' times before giving up in the event of error (default is 1 million).
  • /IPG:n tells Robocopy to pause 'n' milliseconds between packets for network transfers. Useful to preserve bandwidth on slow lines.
  • /B opens files in backup mode. Backup mode allows files to be opened without regard for access control list security restrictions on folders or files. The use of Backup mode requires the Backup and Restore rights which are set up in the Windows operating system's user manager. Contrary to what may seem like this option's purpose, backup mode does not allow access to files that are locked for use by another application. On Windows Vista, the command prompt being used to run Robocopy must also have been run as administrator in order to use backup mode.
  • /L pretends to do the copy without actually doing it, which is useful for testing a command line without being committed to the results.

[edit] See also

[edit] References

  1. Robocopy.exe, Microsoft Windows Server 2003 Resource Kit, help output when run with /? command line switch. Complete help with /??? command line switch.