The Developer's Tidbit

January 21, 2008

SyncToy the GUI Alternative to Robocopy

Filed under: backup, vista, windows — Ben @ 1:43 pm
Tags: , , , ,

In my last post I spoke about the benefits of using a Microsoft tool known as Robocopy for large file transfers, backing up and synchronisation. Well for those who are not comfortable with using a command line interface program or those that simply prefer the convenience of using a GUI. Well Microsoft has released an alternative, though less feature rich, free PowerToy known as SyncToy.

SyncToy currently comes in two editions, 1.4 and a 2.0 that is currently in beta. This article will cover the 2.0 beta which is more feature complete and should be stable enough for most user environments. It is currently available for both Windows XP and Vista and can be downloaded from Microsoft Download Centre.

Some of SyncToy 2’s benefits include

  • The ability to mirror two directories including the renaming and deletion of files and directories
  • The ability to copy from left to right directory or vise versa
  • Support for network UNC paths
  • Support for external devices such as flash drives, cameras, or even music players
  • Ability to preview changes before they are committed to
  • The option of copying all deleted files into the Recycling Bin
  • Filtering by file names, extensions and attributes

How to use SyncToy 2

When you run SyncToy 2 you are first greeted by a menu displaying your folder pairs.

So select Create New Folder Pair and this dialog should appear.

This enables you to select the two directories you wish to synchronise. Generally Left Folder should be your source and Right Folder should be your destination. You will then be asked what do you wish to do with these files. Synchronize, Echo or Contribute. Hovering your mouse over each radio text will give you a a brief description. But normally if you want to clone directories use Synchronize . Otherwise use Echo. If you don’t ever want files to be deleted during the echo synchronizing then you should use Contribute.

Name your folder pair and that will be it.

If you want you can customise the options for your pair including file filtering.

Else you can just preview it to make sure it works as expected.

Now if the preview was successful you can press Run and your synchronisation will now take place. That is all there is too it!

January 17, 2008

Robocopy Basics

When it comes to copying large amounts or large in size files and directories many people don’t realise there are better tools for the job then the built in File Explorer used by Windows. Robocopy is a free command line application created by Microsoft that is perfect for copying large or even huge amounts of data between hard drives or over networks.

Robocopy or ‘Robust File Copy’ was first introduced as part of the Windows Resource Kit but has now been included as default in copies of Windows Vista. So what makes robocopy a better choice then either Windows Explorer, copy or the old DOS xcopy command?

Pros:

  • It can tolerate network outages, retry and attempt to resume the file transfer a set number of times making it perfect for wireless connections.
  • Can copy all NTFS attributes including owner and auditing information.
  • Has a mirror mode to synchronise the target directory with the source making them identical.
  • Uses a detailed verbose mode that keeps you up to date with all the active transfers.
  • Is robust and quick, enabling the transferring of many gigabytes worth of data.
  • You can throttle it’s bandwidth usage so the file transfers do not hog the network connection.
  • Can copy copy destination content of symbolic links.

Cons:

  • It uses the command prompt and has a myriad of options that can be confusing for the first time user.
  • You can only copy directories, not individual files (though you can filter out or in types and names of files you don’t want transferred).

Here are a few common attributes I use with Robocopy.

Mirroring a directory with a UNC (network connection) target
robocopy "c:\my source directory" "\\Server\my target directory" /MIR /XF *.bak *.tmp /XA:ST /W:5 /R:5

/MIR MIRrors a directory
/XF *.bak or *.tmp Excludes files, in this case anything that has the extensions .bak or .tmp
/XA:ST Exclude files with either System or Temporary attributes
/W:5 Wait 5 seconds between retries (default is 30 seconds)
/R:5 Attempt up to 5 retries on a failed copy (default is normally a million)

If you have shortcuts within your directories and you don’t don’t their destination content transferred you can also use the /XJ attribute which ‘excludes Junction points’

And if you wanted to copy all the file and directory security details you can use /SEC

Copying files within an age bracket
robocopy "c:\my photos" "d:\my recent photos" /NOCOPY /MAXAGE:30 /R:0
Now while the first example used an UNC target but this doesn’t have to be the case. Here we are copying to a different hard drive on the same computer and we’re filtering the files by an age group.

/NOCOPY Ignores the individual file attributes and copies only the files themselves.
/MAXAGE:30 Only copies files that are 30 days old or less.
/R:0 Zero number of retries means if an error is encountered robocopy will skip it and just continue onto the next file.

This is result after I copied over 11,600 images (nearly 28gigs worth) over a 100Mbps ethernet connection using robocopy

Robocopy screenshot

Try that with XP’s built in Explorer and you won’t get very far.

Blog at WordPress.com.