Share via


Synchronizing by using Archives

Applies To: Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP

The Web Deployment Tool (Web Deploy) facilitates the synchronization of Web sites and Web servers. A synchronization operation can be performed between two IIS 6.0 Web sites or Web servers, between two IIS 7 Web sites or Web servers, or from an IIS 6.0 source to an IIS 7 destination.

Warning

Synchronization from IIS 7 to IIS 6.0 or earlier versions of IIS is not supported.

This topic will show you how to synchronize Web sites and Web servers by using Web Deploy's archivedir provider. The following outline lists the main steps that you will take.

  1. Use the Web Deploy getDependencies method to get the dependencies that exist on the source computer.

  2. Pre-install or configure the dependent components on the destination site or server.

  3. Create an archive of the source Web site or Web server, and copy the archive of the source to the destination computer.

  4. Make a backup of the destination Web server.

  5. Create and test the Web Deploy command that you will use. The -whatif operation setting will enable you to see the outcome of the operation without actually making any changes.

  6. Run Web Deploy on the destination server to synchronize the archived Web site or Web server to the destination computer.

  7. Verify the results.

Each of these steps is explained in the following sections.

View dependencies

Before you perform synchronization, you will have to determine which components must be pre-installed or configured manually on the destination server or Web site. To do this, run a command in the following format on the source computer:

msdeploy -verb:getDependencies -source:<sourceProvider>

  1. To determine the value of <sourceProvider>, see the following table.

    IIS Version Web site Web server

    IIS 6.0

    metaKey=/lm/w3svc/1

    webServer60

    IIS 7

    appHostConfig="Default Web Site"

    webServer

    For Web sites, substitute the metabase path or Web site name that you will be using. For example, if you want to examine the dependencies on an IIS 6.0 Web site that has the site ID of 1, you would use the following command:

    msdeploy -verb:getDependencies -source:metaKey=/lm/w3svc/1

  2. If you are synchronizing a Web site, review the output of the getDependencies to look for any script maps or installed components that are being used by the site. For example, if Windows authentication is being used by the Web site, you will see the entry

    <dependency name="WindowsAuthentication" />

Warning

If the source is an IIS 7 Web site, make sure that you examine the Web.config file for script maps. The getDependencies method will not detect any script maps that are in a Web.config file.

  1. Based on the output of getDependencies, create a list of the components that you must install or configure on the destination. For detailed steps about how to analyze the output of the getDependencies method, see Viewing Dependencies.

Preconfigure the destination

Use the list from the previous step to install or configure any necessary components on the destination server or site. For example, the following could be in use on your source Web site:

  • ASP.NET

  • Windows authentication

  • Anonymous authentication

Based on this analysis, you must install these components and modules on your destination site or server before you perform a synchronization.

Create an archive of the source and copy it to the destination

  1. Now, create an archive of the source Web site or Web server that will become the source of data for the destination computer. To do this, run a command in the following format on the source:

    msdeploy.exe -verb:sync -source:<sourceProvider> -dest:archivedir=<directoryPath>,encryptPassword=<password> >msdeployarchive.log

    For <sourceProvider>, use the value that you chose earlier in the View Dependencies section. The <directoryPath> value can be a directory path of your choice (for example, c:\archive). For later reference, you can redirect the results of the archive operation to a log file (for example, Msdeployarchive.log).

       

Important

If the source contains secure properties that require a password, use the encryptPassword provider setting as in the example and provide the appropriate value for <password>. Otherwise, you may receive the message "Error: The property 'value' is marked as secure. An encryption password must be specified in order to deploy this property."

  1. After the operation completes, copy the archived folder and all its files to the destination server.

Backup the destination

Before you perform a synchronization operation, make a backup of the destination. Making a backup lets you restore the state of your server easily, even in a test scenario. You can name the backup in any way that is meaningful to you (in the following examples, the name "PreMsDeploy" is used).

  • To make a backup on IIS 6.0, type the following command at a command prompt:

    iisback /backup /b PreMsDeploy

  • To make a backup on IIS 7, type the following command at an elevated command prompt:

    %windir%\system32\inetsrv\appcmd add backup "PreMsDeploy"

  • To restore from a backup on IIS 6.0, type the following command at a command prompt:

    iisback /restore /b PreMsDeploy

  • To restore from a backup on IIS 7, type the following command at an elevated command prompt:

    %windir%\system32\inetsrv\appcmd restore backup "PreMsDeploy"

Create the command and test it

To synchronize a Web site or Web server from the archive to a destination computer, run a Web Deploy command in the following format on the destination computer:

msdeploy -verb:sync -source:archiveDir=<directorypath>,encryptPassword=<password>  -dest:<provider>-whatif >msDeploy.log

  1. For the -source argument, use archiveDir=<directorypath>, where <directorypath> should be the folder on the destination computer that contains the archive that you copied (for example, c:\archive). To determine the value of the destination <provider>, refer to the following table. For compatibility reasons, use the IIS 6.0 provider for the -dest argument when you do a sync operation, even though you are synchronizing to an IIS 7 computer. For Web sites, use the metabase path or Web site name of the Web site that you will be synchronizing.

    What to synchronize Synchronize IIS 6.0 to IIS 6.0, or IIS 6.0 to IIS 7 Synchronize IIS 7 to IIS 7

    Web site

    metaKey=lm/w3svc/1

    appHostConfig="Default Web Site"

    Web server

    webServer60

    webServer

  2. Add the Web Deploy operation setting -whatif to the command. This will enable you to test the command without actually making any changes.

  3. Finally, redirect the output of the command to a log file so that you will have the results available for easy reference and analysis. For example:

    >msDeploy.log

    The completed command should look like the following command, which synchronizes an archived IIS 6.0 Web site with the destination computer.

    msdeploy -verb:sync -source:archivedir=c:\archive,encryptPassword=<password> -dest:metakey=lm/w3svc/1 -whatif >msDeploy.log

  4. On the destination server, run the command you have created to test it. Because you are using the -whatif operation setting, no changes will be made.

Run the command on the destination server

  1. After you have verified that the output is what you want, run the command on the destination computer again, but without the -whatif operation setting. For example:

    msdeploy -verb:sync -source:archivedir=c:\archive,encryptPassword=<password> -dest:metakey=lm/w3svc/1 >msDeploy.log

  2. After the sync operation is completed, test browse the Web site on the destination server.

  3. If you need help with troubleshooting, see Web Deploy Troubleshooting Techniques.

Summary

You have now synchronized a remote Web site or Web server source to a destination computer. To do this, you discovered the dependencies that existed on the source and installed the necessary components on the destination. You then created an archive of the source by using Web Deploy. You copied the archive to the destination computer. After making a backup of the destination Web site or Web server, you created and tested the Web Deploy command. You ran the command on the destination server and verified the results. At various stages of the operation, you redirected the output of the Web Deploy tool to a log file for easy reference and troubleshooting.

See Also

Web Deploy archiveDir Provider

Archiving and Restoring a Web Site

Synchronizing from a Remote Source

Web Deployment Tool Core Tasks

Viewing Dependencies

Creating and Synchronizing a Custom Manifest