SOLVED: How To Copy Permissions and Files At the Same Time

I had a bad VHD that I was unable to copy, I would get CANNOT READ SOURCE… after about 30%.  Then I tried to build a new VHD using the COPY CONTENTS… function in HyperV but that failed at about 30% too.  Now I was getting worried.  Fortunately the VHD would start and function without apparent error in its HyperV VM, so I could copy the files and folders but who wants to rebuild all the permissions… not me.  The answer was the simple command line tool RoboCopy!robocopy-copy-permissions

Robocopy, which is short for Robust Copy, originally came in the Windows NT4 (yes, in the 1990’s) Windows Resource Kit which you had to buy separately.  It was built to transfer files over unstable links, specifically satellite links.  That puts a WOW in WAN!  Regardless it has come and gone in popularity over the 2000’s but now is built into the operating system of Windows 8, 10, Server 2012, Server 2012 R2 and Server 2016, so it is a tool all administrators should at least have an awareness of.

The command I used was:

robocopy  \\<server>\<share> T:\<share> /COPYALL /ZB /R:2 /W:2 /E

The switches mean:

\\<server>\<share>  = source location

T:\<share> = destination location. in my case it was on the T:\ drive

/COPYALL = copy the shares and permissions

/ZB = restartable mode so it will pickup if there is a bump

/R:2 = the number of retries in case the file is in use or has a problem

/W:2 = the number of seconds to wait between retries

/E = copy EVERYTHING including subfolders and empty subfolders

If want to read more about this type robocopy /??? and you will see the most documentation in a an integrated help file you have ever seen.  Alternately, you might find THIS post helpful and THIS Wikipedia page interesting

Comments

  1. Avatar
    vikas khandola February 12, 2018 at 11:27 am

    use robocopy

Questions or Comments?