Web Site Content Migration or Synchronization with Web Deploy
This method is used to migrate web site files to a new server or synchronize the files between two servers.
The contentPath provider enables you to dump, synchronize, or archive all content of the path specified. The path selected can be a physical directory path, file path, or an IIS Web site or application path like Contoso/Benefits.
By specifying an IIS Web site or application path, the provider will retrieve content separately from certificates, assemblies, or IIS configuration data and will synchronize just the files.
Here is the link to the TechNet content about the contentPath provider- https://technet.microsoft.com/en-us/library/dd569034(v=ws.10).aspx
Note: This scenario can only be accomplished with the Web Deploy command line.
Example Syntax:
msdeploy -verb:sync -source:contentPath ="Contoso.com" -dest:contentPath="Contoso.com",computername=10.0.0.12
- Web Site = Contoso.com
Migration Options:
The syntax presented in this blog post uses the web site path and the other options are the following:
- A directory path (for example, c:\web\contoso)
- A file path (for example, c:\web\contoso\main.htm)
- A site path (for example, "Contoso" or MySite)
- An application path (for example, "Contoso/Benefits"or Contoso/Benefits/default.htm)
Verify before Execution:
From the command prompt, enter the following commands to create a differencing file and mechanism to review errors and warnings before generating the package file:
msdeploy -verb:sync -source:contentPath="Contoso.com" -dest:contentPath="Contoso.com",computername=10.0.0.12 -whatif > c:\_WebDeploy\ContosoDiff.txt
Inspect the output in the text file by searching on Error and Warning and resolve the issues before generating the package. Again, the pipe command to the file is optional and output from the WhatIf command can be viewed within the command window.
Note: If the application on the Target does not exist, the output from the -whatif statement will show all adds and no deletes.
Package Transfer Method:
Create Application Package on Source Server:
Command Line:
msdeploy -verb:sync -source:contentPath="Contoso.com" -dest:package=c:\_WebDeploy\Contoso.zip
Copy the Web Deploy package to the new server.
Import Package on Remote Server:
Command Line:
msdeploy -verb:sync -source:c:\_WebDeploy\Contoso.zip -dest:contentPath="Contoso.com" > c:\_webdeploy\ContosoDeployment.txt
Command Line Method without Packages:
This method generates a server to server transfer of the web application and omits the use of packages. It will synchronize the differences between the source and the target server at the application level.
msdeploy -verb:sync -source:contentPath="Contoso.com" -dest:contentPath="Contoso.com",computername=10.0.0.12 > c:\_WebDeploy\ContosoDeployment.txt