Freigeben über


Synchronizing by using Packages

Applies To: Windows 7, Windows Server 2003, Windows Server 2003 R2, 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 package provider. The package provider compresses Web server or Web site content into a compressed file in .zip format called a package. 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 a package (.zip) file of the source Web site or Web server, and copy the package file 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 packaged 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, 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 a package of the source and copy it to the destination

  1. Now, create a package 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:package=<packageFilePath>,encryptPassword=<password> >WebDeployPackage.log

       

    For <sourceProvider>, use the value that you chose earlier in the View Dependencies section. The <packageFilePath> value is a file path of your choice to the package file that you want to create (for example, c:\Server1Package.zip). For later reference, you can redirect the results of the package operation to a log file (for example, WebDeployPackage.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 package file to the destination server.

Backup the destination

Before you perform the synchronization operation, make a backup of the destination server. 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 "PreWebDeploy" is used).

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

    iisback /backup /b PreWebDeploy

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

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

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

    iisback /restore /b PreWebDeploy

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

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

Create the command and test it

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

msdeploy -verb:sync -source:package=<packageFilePath>,encryptPassword=<password>  -dest:<provider>-whatif >WebDeploy.log

  1. For the -source argument, use package=<packageFilePath>, where <packageFilePath> is the .zip file on the destination computer that contains the package that you copied over from the source (for example, c:\Server1Package.zip). 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:

       

    >WebDeploy.log

       

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

       

    msdeploy -verb:sync -source:package=c:\Server1Package.zip,encryptPassword=<password> -dest:metakey=lm/w3svc/1 -whatif >WebDeploy.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: package=c:\Server1Package.zip,encryptPassword=<password> -dest:metakey=lm/w3svc/1 >WebDeploy.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 a compressed (package) file of the source by using Web Deploy. You copied the package file to the destination computer. After making a backup of the destination Web server, you created and tested the Web Deploy command by using -whatif. 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 package Provider

Viewing Dependencies

Web Deployment Tool Core Tasks