How to Synchronize a Website Between Two IIS 6 Servers Using MSDeploy

Ever since the days of Windows 2000’s debut, one of the more popular ways of synchronizing content and IIS configurations between servers was to use Microsoft Application Center.  Though that tool still works on 2003 Server (mostly), I’ve been trying to phase it out of our environment since it is an end of life product that is no longer supported by Microsoft.  I went looking for a quick and cheap (free) way to replace this functionality, and was happy to find out that MSDeploy can fill this void.  I’ve documented in previous posts the process of using MSDeploy to synchronize between IIS 7 servers, and luckily the process isn’t much different when you need to do it on IIS 6 boxes.

Here’s what you’ll need to do in order to synchronize both content and configuration for a particular website between IIS 6 servers:

  • Create your website on the source server.
  • Download the latest version of the Web Deployment tool from http://www.iis.net/extensions/WebDeploymentTool .  Make sure you get the correct version for your environment – x86/x64
  • Run the install on each server that you want to synchronize, choosing Complete to install all components .
  • Create a folder on your source server to store the deployment scripts in.  I use E:\WebsiteSyncJobs
  • Create a folder within there for each website that you want to synchronize.
  • Open notepad and create a batch file using the info below as a template.

      @ Echo Off
      ECHO Starting Deployment on %DATE% at %TIME% >>msdeploySync.log
      ECHO Starting Deployment on %DATE% at %TIME%
      sc \\DESTINATION_SERVER_NAME start msdepsvc >>msdeploysync.log
      “C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe” -verb:sync -source:metaKey=lm/w3svc/1 -dest:metaKey=lm/w3svc/1,computername=DESTINATION_SERVER_NAME -enablelink:AppPoolExtension >>msdeploysync.log
      sc \\DESTINATION_SERVER_NAME stop msdepsvc >>msdeploySync.log
      ECHO Deployment Complete on %DATE% at %TIME% >>msdeploysync.log
      ECHO Deployment Complete on %DATE% at %TIME%
      ECHO ——————— >>msdeploysync.log

      pause

  • Edit the values to match your website and server names.  Replace DESTINATION_SERVER_NAME with the name of your destination server.  You’ll also need to modify the metakey value to match the website that you’re trying to move.  The default website will always be #1, but subsequent websites will be assigned a random number.  You can find the metakey identifier for your website by opening Inet Manager on your source server and clicking on the Websites Folder.

image

  • Save the file with a name that will make it easy to identify.  For example, test.website.com_to_Server2.bat
  • Run the batch file.  Once it is done, open up the msdeploySync.log file and check for any errors.

If everything is good and there were no issues then the site should now show up on the destination server.  You should run the sync script anytime you make content or configuration changes to the website on the source server, that way everything will always match up.  You could also easily schedule the synchronizations using Task Scheduler.

Leave a Comment

Filed under IIS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s