Using Robocopy to copy or sync files, while preserving permissions

Robocopy stands for “Robust Copy”, which can be used to robustly copy files from one location to another.  It comes standard with Windows Server 2008. It is very handy when copying large datasets or sensitive permissions.  Many options are available, but we find these to be most useful when copying lots of data.

To use this tool you will need to start the command prompt.  The robocopy tool should already be in your path so you can use it right away.

robocopy D:\Folder1 E:\Folder2 /MIR /R:1 /W:1 /COPYALL

This will perform the robocopy command, and specify to “Mirror” (/MIR)  Folder1 to Folder2.  This will take care of any differences in the hierarchy of files and directories.  Anything from Folder1 that is not in Folder2 will be added.  Anything that is in Folder2 that is not in Folder1 will be removed, and so on.  /R and /W will set number of re-try’s and intervals for if files fail.  /COPYALL will preserver all timestamps, permissions, ACL’s and other attributes.

An interesting thing is that sometimes performing this copy may make the top folder be hidden.  Perhaps this is a windows bug?  Who knows.  You can unhide id by doing the following:

attrib -h -s Folder2

This will unhide the folder/file.  You should be all set!

Be the first to comment

Leave a Reply