| Introduction If you're like me, you probably do your best to ensure that the .NET applications you build contain as few external dependencies as possible. Doing so makes them easier to deploy and maintain, since all you need to do is copy the application's files to a new server and you should be good to go. This has come to be know as XCOPY deployment, after the venerable XCOPY command that has been around since the days of DOS. These days I actually use ROBOCOPY and batch files instead of XCOPY for most tasks, but the basic concept is the same. As great as the XCOPY method of deployment works, it requires that the user be reasonably comfortable using the command line. Recently Microsoft released version 2 of a simple little utility called SyncToy which gives users who prefer a GUI a similar level of functionality. In this article I'll cover the basics of obtaining, installing, and using this useful little tool. Installation The first step is obviously to get and install SyncToy v2.0. You can download the installation package directly from Microsoft: SyncToy v2.0 (4.2 MB). While you're there, do yourself a favor and give the overview a quick read. Once you've downloaded it, the next step is installation. For such a simple utility, the installation seems to have a lot of steps, but there aren't any real options that you need to change... just agree to all the license agreements and keep clicking the "Next" button and you'll be done in a few seconds. There's no need to examine the images below closely... I simply included them to give you an idea of what to expect. Once you've installed SyncToy v2.0, you should find an icon for it in the "All Programs" folder on your "Start Menu". Click the icon to to run the program. Creating a Folder Pair When you launch SyncToy 2.0 for the first time, you'll be greeted by the following welcome screen. Once you're in the SyncToy program the first step is to set up what's called a "Folder Pair". Setting up a "Folder Pair" consists of three steps. The first step is to choose a "Left Folder" and a "Right Folder". SyncToy calls these "Left" and "Right" because, in some configurations, files are copied in both directions. If you're using SyncToy as a replacement for XCOPY (or a similar tool), it's best to think of the "Left Folder" as the source and the "Right Folder" as the destination. Step two is where you tell the program what you want it to do with the files. There are three options: - Synchronize: New and updated files are copied both ways. Renames and deletes on either side are repeated on the other.
- Echo: New and updated files are copied left to right. Renames and deletes on the left are repeated on the right.
- Contribute: New and updated files are copied left to right. Renames on the left are repeated on the right. No deletions.
For backing up files or one way publishing (where you don't need to worry about overwriting changes on the destination) you'll probably want to choose "Echo", but the action you choose will naturally depend on your individual situation. Warning: Echo will delete any files present in the destination folder that are not the same as those in the source. I recommend you be very careful to use an empty folder as the "Right Folder" and by all means please check the preview carefully before running a "Folder Pair" configured for Echo. Please be careful when using this option. The final step to setting up a "Folder Pair" is giving the pair a friendly name by which you will refer to it later. Choose something short and simple, but descriptive enough so you know what it does. Here you can see our new "Folder Pair" displayed in SyncToy's main window. Folder Pair Options Once you've created your "Folder Pair", you might want to take a look at the available options before you "Run" it for the first time. This is where you can tell SyncToy which files to include and exclude from the copy, if it should move overwritten files to the Recycle Bin, if it should check each file's contents (in addition to their size and timestamp) to determine changes, and other options like that. Preview and Run Once you're happy with all the settings, it's time to give your new "Folder Pair" a trial run. Because syncing folders can take some time and can actually delete files, SyncToy includes a "Preview" option which will create a report telling you what it will do without actually performing the syncronization. I highly recommend you perform a preview and check to make sure the results are what you expected before you actually run the syncronization for the first time. Once you've run it a few times there's no need to bother with the preview step, but whenever you're not sure it's best to play it safe. Of particular interest is the "Preview Results" summary near the bottom of the screen which will tell you the number of files that will be affected by each operation as well as the total bytes the syncronization will require. Once you're satisfied with the preview results, you simply click the "Run" button and sit back while SyncToy does it's thing. Command Line Execution / Scheduling SyncToy I won't go into much detail since the help file does a good job of covering it, but I just wanted to mention that SyncToy 2.0 does include a command-line interface which allows you to script it or schedule it to run automatically. You can find the topics ("Run SyncToy From Command Line" and "Schedule SyncToy") under "SyncToy How To Topics" in the SyncToy help file. Conclusion I hope this article has given you a quick and easy introduction to Microsoft's SyncToy v2.0. It's a shame they named it SyncToy, because while it may be easy to use, it's actually quite a powerful little program which provides a nice GUI-based alternative to either manually copying files or using the more complex XCOPY or ROBOCOPY. |