Friday 23 January 2009

SyncToy functionality in Robocopy

Recently I have been using both Robocopy and SyncToy for projects at work and at home. I really like the easy of use of SyncToy but sometimes it doesn't sync files for unknown reasons. It also adds .dat files to the source and destination folders which sometimes isn't desirable. The best thing about SyncToys is the GUI and how easy it is to setup folder pairs.

Robocopy is a very powerful synchronisation program. It has lots of options that you can play with and doesn't add extra files to source or destination, it is very fast, but it isn't very user friendly.

Ideally I want to have the power of Robocopy with the ease of use of SyncToy.

There are 3 options that you have in SyncToy 2.0 for synchronising folders. The 3 options are:

  • Synchronise
This is a two way synchronise where new, updated and deleted files are propergated to the source and destination folders. Use this with care as you can delete a lot of files very quickly when using this method.
  • Echo
This is one way synchronisation where new, updated and deleted files on the source are propergated to the destination folder. You could think of this as option as a one way mirror operation. This the main option when I use SyncToy
  • Contribute
This again is one way synchronisation but no deletes are carried through to the destination folder. We have used the contribute method at work where one of the departments was going out to gather information from a number of off site locations. They did this by using an external hard drive and copying files from the external location to the external drive. When back at base we have a folder on the network that is used to store all the data from all sites. We synchronised the external hard drive with the network location when we get back to base. The good thing about using contribute is that your source and destination don't have to match as SyncToy will only take new or updated files from the source and move them to the destination. So in our case we had a relatively small external hard drive and a large network drive where the data from all external sites was deposited.

So the question is how can we replicate the three SyncToy options in Robocopy.

Echo

/MIR = Copy Subfolders, including Empty Subfolders and delete all folders from destination not in source
robocopy C:\Source C:\Destination /MIR

Contribute

/E = Copy Subfolders, including Empty Subfolders

robocopy C:\Source C:\Destination /E

Synchronise

Not sure about this one as there was no switch or group of switches to that I could find to replicate this functionality. There must be a way of doing this but not sure how. You may have to run robocopy twice and swap over the source and the destination when running it the second time.


I have only just scratched the surface of Robocopy. View the full list of parameters to see how much more there is to Robocopy. For example you can log all jobs by using /LOG:filename and you can do a dummy run by using /L (Highly recommended).


Robocopy comes preinstalled with Windows Vista and can be downloaded for Windows XP / Windows 2003 for free as part of the Windows 2003 Resource Kit Tools

3 comments:

Anonymous said...

You're right with simulating the Synchronise option by running Robocopy twice. This is described in the Documentation that comes with Robocopy (robocopy.doc) in the "Using Robocopy File Classes" section:
"The most appropriate use for /XO is to synchronize two directory trees so that they can be updated simultaneously in separate areas. To ensure that the latest files are present in both directory trees, copy with /XO first in one direction and then in the other."

/ch

Anonymous said...

I'm having the same issue. Unfortunately using /XO seems to be contrary to /PURGE?
So of course all newer files will be copied appropiately, but deleted files will be "restored". Or am I wrong?

Anonymous said...

Hey, you can just use ViceVersa PRO, which is exactly that, robocpy + synctoy! see http://www.tgrmn.com