Microsoft‎ > ‎Windows‎ > ‎Commands‎ > ‎

Robocopy

in my opinion, robocopy is one of the most useful utilities that comes with Windows. in the IT profession, i use it every day.

Robocopy

Syntax:

Robcopy "source path" "destination path" {switches}

Useful Switches:
  • /e - include subfolders in copy
  • /z - use network (restartable) copy mode
  • /xd "foldername" "foldername2" - exclude folder(s) from copying
  • /xf "filename" "filename2" - exclude file(s) from copying
  • /w:1 - wait one millisecond before reattempting a copy (if there is a problem accessing a file)
  • /r:1 - retry copying each file only once (if there is a problem accessing a file)
Example:

robocopy "c:\_backup" "\\fs1\backups" *.bak /e /z /w:1 /r:1 /xd test

Breakdown of the above command:

Source folder: c:\_backup (yes, you can use UNC paths as long as you have access)
Destination folder: \\fs1\backups (yes, you can use UNC paths as long as you have access)
*bak = Copy only ".bak" files
/e = copy files from subdirectories
/w:1 = wait one millisecond before reattempting a copy (if there is a problem accessing a file)
/r:1 = retry copying each file only once (if there is a problem accessing a file)
/xd test = exclude the "test" directory from copying




Comments