Robocopy is a tool provided by Microsoft that provides a robust way to move files. It comes built in to Windows 7, Windows 8, Server 2008, Server 2008 R2, and Server 2012. It can also be downloaded for Server 2003. If you’ve ever had a problem with file names being too long or copy jobs getting stuck waiting for input using Windows Explorer, you’ll love Robocopy.
Copy Data *without* Attributes
If I just want to copy data from one place to another, and I don’t care about dates or file permissions being copied with the data, I’ll use the following command because it’s so easy to remember. The
/e switch tells Robocopy to copy subdirectories even if they’re empty.
Copy Data *with* Attributes
If I DO care about file permissions and other attributes being copied to the file destination, I use Robocopy with the following switches. I typically like using this if I am moving data from one file server to another.
robocopy /e /dcopy:t /copyall /r:1 /w:1 /v /tee /log:copylog.txt
Here is a breakdown of what the switches do:
/dcopy:tcopies the directory time stamps.
/copyallcopies all file information including NTFS permissions and owner information.
/r:1specifies the number of times Robocopy will attempt to copy the file. In this case, it will try once.
/w:1specifies how long Robocopy will wait between retries. In this case, it will wait one second before retrying.
/vshows verbose output when you run the Robocopy command.
/teewill cause Robocopy to write output to the console and to the log file.
/log:copylog.txttells Robocopy to save the log to a file called copylog.txt.
Copy Data that has Changed
If you’ve already run Robocopy once and just want to copy new or changed data, simply add the
/xo switch to the end of your Robocopy command.
For more information, check out the TechNet article.