Category Archives: Windows

Migrating data with robocopy

Few days back I had a situation when I needed to migrate data from one Windows 2003 server to another.

The data contained 2 level of directories and thousands of files in them.

Also the data needed to copied with ACL as well.

so I wrote a script on source server as below to speed up copy.

D:

cd D:\data

For /D %%r in (*) do (

For /D  %%a in (*) do(

cd %%a

start robocopy.exe D:\data\%%r\%%a \\destination\data\%%r\%%a *.* /e /s /w:3 /r:3 /XX /XO /SEC /LOG:c:\robocopy_%%r_%%a.log)

)

I created log file to retain the dir and files list which were copied.

What I did with script is I queried for all directories in D:\data and I again queried the directories under D:\data\DIRECTORIES.

Then I used robocopy utility from Windows server kit to start copying each directories and files at the same time with start command.

If you don’t put start in front of robocopy it will still copy, but it will copy one directory at a time.

Hope this solution will help some other people who may require it.

Please comment suggestions for improvement or what solution you would use to complete this kind of task.