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.
/ | ||
An idea using ThreadPool and seeing errorlevel status for each task.ReplyDelete
Hi thank you for sharing. Great Post.ReplyDelete
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.
The file type and logging could be done in robocopy command line string at line 39. For exampleDelete
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
Hi and thank you for sharing your script.... I use it to copy my files til BitCasa.ReplyDelete
I have a question you maybe can help me with.
For every output I make a logfile like this:
txtOutput.Write "start robocopy *.* """ & Source & "\" & objFolder.Name & """ """ & Destination & "\" & objFolder.Name & """ /MIR /log+:\\Freja\Faelles\Faelles_filer\SkyDrive_MAB\Logfiles\""" & objFolder.Name & """\Bitcasa_" & LogFile & "_""" & objFolder.Name & """_%date%.txt /np /r:3 /w:1 /XF" & vbCrLf
And that gives me a lot of logfiles.
What I would like is to store the logfiles in seperate directories. for each objFolder.Name
How to do that...
I have tried with this code:
IF NOT EXIST "" & Source & "\" & objFolder.Name & "" mkdir "" & Source & "\" & objFolder.Name & ""
But it does not Work.
Thanks in advance.
I found a solution:Delete
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
If NOT (FSO.FolderExists("\\Freja\Faelles\Faelles_filer\SkyDrive_MAB\Logfiles\" + LogFile)) Then
FSO.CreateFolder("\\Freja\Faelles\Faelles_filer\SkyDrive_MAB\Logfiles\" + LogFile)
This is put in just after:
For Each objFolder in colFolders
What I would like now is to remplace: