This is a place for Systems Administrators and IT Professionals to find and share ideas, solutions and templates. If you have something that helps you solve a problem, chances are it will help someone else too. So pay it forward and send an email to TheAgreeableCow at gmail. Full mudos to you!

Wednesday, 6 June 2012

Using multiple copy streams with Robocopy

This is a quick post to outline a technique I've used to migrate file servers using robocopy - or to be specific, lots of parallel robocopy streams.

The script works best when you have multiple 2nd level sub-directories contained in the root directory. The VBS file below parses the directory names into seperate robocopy command line statements inside a new batch file. When the batch file(s) are run, a seperate robocopy stream is processed for every sub-directory at the same time.

All of the usual robocopy command switches can be used of course. For one off jobs, these multiple parallel streams are much faster than a single stream. It's also great for syncronising file stores if run as a sheduled task.

Here is the code.

         (oo)  ok
   /------\/  /
  / |    ||
 *  /\---/\
    ^^   ^^


  1. An idea using ThreadPool and seeing errorlevel status for each task.

  2. Hi thank you for sharing. Great Post.
    Very clean and detailed
    I would like to ask for some flavours :)
    how to do this by adding another variable like every destination or source I just want to copy a specific kind of file (exemple: *.101 form source1/destination, *.102 from source2/destination2)
    And how to make a log file for each day resuming all.


    1. The file type and logging could be done in robocopy command line string at line 39. For example

      txtOutput.Write "start robocopy *.101 " & Source & "\" & objFolder.Name & " " & Destination & "\" & objFolder.Name & " /w:1 /r:1 /MIR >> c:\temp\copy101.log" & vbCrLf

      If you wanted to match a specific file type just to a specific source, then you would just create multiple "createscript" functions, with the appropriate command line string. These would be then be called accordingly. eg

      CreateScript101 Source1,Destination1,BatchFile1
      CreateScript102 Source2,Destination2,BatchFile2