Condividi tramite


Synchronizing from a Remote Source

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

The Microsoft 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.

This topic shows you how to use the Web Deploy remote service to synchronize Web sites and Web servers. In this topic, the remote computer will be the source, and the local computer will be the destination. 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.

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

  3. Make a backup of the destination.

  4. 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.

  5. Run Web Deploy on the destination server to synchronize the remote Web site or Web server source to the local computer.

  6. Verify the results.

Each of these steps is explained in the following sections.

View dependencies

Before you perform a sync operation, 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:

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 a 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 method 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 this 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. During a sync operation, Web Deploy will detect the dependencies that are being used and report whether they are installed 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 components 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 the destination before you perform a synchronization.

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, run a Web Deploy command in the following format on the local destination (not the remote source) computer:

msdeploy -verb:sync -source:<provider>,computerName=<host> -dest:<provider>-whatif >msDeploySync.log

  1. To determine the value of <provider>, see the following table. Use the same provider for both the -source and the -dest arguments. For compatibility reasons, use the IIS 6.0 provider for both the -source and -dest arguments when you do a sync operation. 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. For <host>, use the computer name of the remote source. The computer name (for example, "Server1") will be converted to the default Web Deploy URL of the format https://Server1/MsDeployAgentService. If you are running the Web Deploy remote service on a non-default port or URL, you must specify the full URL.

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

  4. 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:

    >msDeploySync.log

    The completed command should resemble the following, which synchronizes two IIS 6.0 Web sites. Note that there is no space between the comma and the computerName provider setting.

    msdeploy -verb:sync -source:metakey=lm/w3svc/1,computerName=Server1 -dest:metakey=lm/w3svc/1 -whatif >msDeploySync.log

  5. 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:metakey=lm/w3svc/1,computerName=Server1 -dest:metakey=lm/w3svc/1 >msdeploysync.log

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

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

Summary

You synchronized a remote Web site or Web server source to a local computer destination. You chose the appropriate Web Deploy provider based on your version of IIS, and whether you were synchronizing a Web site or a Web server. You identified the remote computer for Web Deploy by using the computerName provider setting. The remote sync operation was made possible by the Web Deploy remote agent service.

See Also

Web Deployment Tool Core Tasks

Archiving and Restoring a Web Site

Viewing Dependencies

Synchronizing by using Archives

Creating and Synchronizing a Custom Manifest