Client Area · 0114 299 4050
View Services

An Introductory Guide to Robocopy

An Introductory Guide to Robocopy
Dan Wynne takes us on a tour of the wonders of Robocopy - Xcopy's more powerful, versatile and better looking sibling.

What is Robocopy? Despite what you may think, it isn’t a silver police robot.

It is actually a command that stands for “Robust File Copy”. Robocopy replaces the more common Xcopy command line data transfer function.

So, why replace Xcopy? Xcopy was first included in DOS 3.2 and for many years was fine for the job, however as technology changed so did our needs, which meant Xcopy was no longer suitable and began to be deprecated after the release of Windows Vista. Robocopy is more powerful and offers far more options.

As I have already said Robocopy is a command line data transfer tool, it is very useful in many situations and is far faster than a simple copy and paste, it also allows users to specify some key ‘switches’ to allow things like keeping file permissions, skip existing files and exclude certain paths.

I am going to take you through some of my most used switches and explain why you would use them...

Using CMD the basic command for Robocopy is:
ROBOCOPY “SOURCE” “DESTINATION”  [remove quotes before running]
This will simply copy everything from the Source location to the destination.

To alter the process, you can add a switch to the command, the switch will perform a certain task.
Some of the ones I use regularly are as follows...

/Z  - Restartable Mode
As it states, this switch will allow the task to restart a file copy should it fail mid transfer, for example network drop outs.

/XD - Excludes Paths e.g. /XD "Temp" "Temporary Internet Files"
Sometimes there is data you do not wish to copy. For example to copy a user profile will also copy temp files, using the /XD switch and specify files as above, Robocopy will skip these files speeding up the transfer.

/XJ - Exclude junction Points (win 7+ issue)
This is a very important switch if you are running robocopy on Vista/7 Machines, especially if the machine was upgraded from XP. You can end up with the copy job getting into an endless loop at the application data folder, use /XJ to avoid this

/R:0 – Retrys
The R indicates retrys and the number how many times. In this example R:0 will retry a file zero times.

/W:0 - Wait between Retrys
Similar to above W:0 is the amount of time to wait between retrys, ideal if the job is over a network and you do not want to flood the network.

/E - Include Empty Dirs
Sometimes you want to copy the entire folder structure, even if the folders are empty. For example, a new server or PC. This switch will allow that.

/COPYALL – Copy ALL file info
This switch will ensure that all file information, permissions and tags are also copied during the task.

If your command is run repeatedly it will skip any files already in the destination, one example of why this would be, is if you want to create a scheduled backup task and the job runs daily. You could also add the /MIR switch if you wanted to Mirror the two directories.

Here I will give you an example of what the complete command could look like
robocopy /Z /E /R:0 /W:0 "source" "destination" /XD "Temp" "Temporary Internet Files" /XJ  [quotes on temp folders are required, but not source/destination].

If you use the guide above you should now be able to see that this job will run in restartable mode, it will copy all empty directories, retry zero times and wait zero seconds, it will exclude the temp folders specified and finally avoid junction points.

One final point to add, in some instances you may wish to see a log file when the task has completed. This can be done with Robocopy. Add /log to the end of the task and specify the location you wish to save the log file, like this example /log:"V:\USER\Shares\robocopyUser.log" [quotes required for log switch]

I hope you find Robocopy and this guide useful! 

< Back to Blog

Popular Posts:

Comments

Please leave a comment



Allowed tags: <b><i><br>



emergency it response: 0114 299 4050 View PAYG Options