Tray on the Web
The ramblings of an IIS/SharePoint Admin and Margarita Connoisseur

Synchronizing a site between two IIS 7 web servers

Friday, July 31, 2009 4:21 PM

When working in a web farm environment, keeping content and configuration in sync is a critical piece of the puzzle.  With IIS 5 and IIS 6 you could accomplish this with Microsoft’s Application Center.  The product certainly has it’s flaws, but once you are able to get it working it is fairly low maintenance.  To this day we still have a couple of production farms running App Center and it’s not something I ever have to worry about.

Unfortunately a few years ago you started hearing that Microsoft was discontinuing any future updates or releases of the App Center product.  To make matters worse, they kept silent on what would replace the functionality that it provided and many people relied on.  That’s where the Web Deployment Tool comes in .  While it still doesn’t offer all of the functionality that App Center did, it’s a good start and they are constantly adding new features to it.  Recently an article was posted which compares the features offered in both App Center and the Web Deployment tool.

What I was looking to do was use the Web Deployment Tool, and specifically the command line tool within it called MSDeploy.exe, to be able to synchronize content and all IIS configuration for a website between a source and destination server.  To do that, follow these steps:

  1. 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
  2. Run the install on each server that you want to synchronize, choosing Complete to install all components
  3. Create a folder on your server to store the deployment scripts in.  I use E:\WebsiteSyncJobs
  4. Create a folder within there for each website that you want to synchronize.
  5. Create a batch file using the info below as a template.  Edit the values to match your website and server names.  For the apphostconfig value, replace sample.website.com with the URL of the website you’ll be synchronizing. For the computername value, replace SERVERNAME with the name of the destination server that you will be synchronizing with.  The below script will create an IIS backup prior to doing anything, and then move over your website and content and write everything to a log.

 

      @ Echo Off
      ECHO Starting Deployment on %DATE% at %TIME% >>msdeploySync.log
      ECHO Starting Deployment on %DATE% at %TIME%
      %windir%\system32\inetsrv\appcmd add backup
      "C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:apphostconfig="sample.website.com" -dest:apphostconfig="sample.website.com",computername=SERVERNAME -enablelink:AppPoolExtension >>msdeploysync.log
      ECHO Deployment Complete on %DATE% at %TIME% >>msdeploysync.log
      ECHO Deployment Complete on %DATE% at %TIME%
      ECHO --------------------- >>msdeploysync.log
      pause

  1. Save the file with a name that will make it easy to identify.  For example, test.website.com_to_SERVER01.bat
  2. Create your website now on the source server if you haven’t already done so.
  3. 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, that way everything will always match up.  You could also easily schedule the synchronizations using Task Scheduler.


Feedback

# re: Synchronizing a site between two IIS 7 web servers

Have you ever used this Web Deployment Tool with any of your SharePoint sites?

I'm not even sure the tool would be needed when working with SharePoint 2007... 9/11/2009 2:57 PM | JoeData

# re: Synchronizing a site between two IIS 7 web servers

Hey Joe, no I've never tried using it with a SharePoint site. I just use this process on our standard .net web sites. I don't think the web deployment tool would be very beneficial in a SharePoint environment because there are some machine specific settings that SharePoint uses in the web.configs. Given that changes to the web code in SharePoint is so rare I find it easier just to do things the old fashioned way. :) 9/11/2009 3:25 PM | Tray

# re: Synchronizing a site between two IIS 7 web servers

Awesome, thanks for the reply Tray 9/14/2009 10:59 AM | JoeData

Post a comment