共用方式為


Simple steps in migration of Websites using WebDeploy

There are numerous articles which talk about the easiest ways of migrating the websites from IIS 7.X to a higher version of IIS using WebDeploy.

This blog illustrates one of the ways to migrate the sites from IIS 7.X to higher version of IIS, when the content drive of the Source machine is not present in the destination.

Example: On the source box, if the Website is pointing to the physical path C:\FolderName and the requirement is to either point the website to the "D:\" drive on the destination box or if "C:\" dive is not present on the destination.

Prerequisites:

Make sure that the WebDeploy is installed on the source box and the destination box.

Steps to be followed:

1. On the source box firstly check the dependencies of the concerned web site navigating to the location where webdeploy is installed and running the below command:

msdeploy.exe -verb:getdependencies -source:apphostconfig="WebSite_Name"

    Based on the output returned by this command, make sure that the dependencies are handled on the destination box.

2.  Run the following command on the source server to create a package (compressed) file of the site. The package.log would have the error (if any) obtained while running the command.

msdeploy.exe -verb:sync -source:apphostconfig="WebSite_Name" -enableLink:AppPoolExtension -dest:package=c:\site.zip > package.log

3.  Since the requirement here is to move the contents from C:\ drive on source machine to D:\ drive on the destination machine. We first need to find the configuration of the web site by running the "dump" operation.

msdeploy.exe -verb:dump -source:package=c:\site.zip -xml> XMLinfo.log

4.  We then need to go through the XMLinfo.log and identify the configuration of the website which are dependent on the C:\ drive. Please see the small portion of the output of the xmlinfo.log file taken from my box:

<application path="/" applicationPool="DefaultAppPool" enabledProtocols="http">

<virtualDirectoryDefaults path="" physicalPath="" userName="" password="" logonMethod="ClearText" allowSubDirConfig="true" />

<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" userName="" password="" logonMethod="ClearText" allowSubDirConfig="true">

<dirPath path="C:\inetpub\wwwroot"

The highlighted section is what needs to be replaced with the different drive. So we can run the below command to replace the source drive to the destination drive:

msdeploy.exe -verb:sync -source:apphostconfig="WebSite_Name" -enableLink:AppPoolExtension

-dest:package=c:\ModifiedSite.zip  -replace:objectName=VirtualDirectory,targetAttributeName=physicalPath,

match="C:\\inetpub\\wwwroot",replace="D:\inetpub\wwwroot"   -replace:objectName=dirPath,targetAttributeName=path,

match="C:\\inetpub\\wwwroot",replace="D:\inetpub\wwwroot"

5. Move the package to the destination box manually and place it any drive (here we have placed it in D:\ drive) and You need run the below command to import it:

msdeploy -verb:sync -source:package=D:\ModifiedSite.zip -dest:apphostconfig="WebSite_Name" -whatif

6. The above command will display if there are any errors.

7. You can then run the same command without the -whatif switch. And there you go..!! You have successfully migrated the website.

Reference articles:

https://www.asprangers.com/post/2013/09/24/Web-Deploy-command-line-(msdeployexe)-Scenario-bash.aspx

https://technet.microsoft.com/en-us/library/dd569089(v=ws.10).aspx

https://www.iis.net/learn/publish/using-web-deploy/migrate-a-web-site-from-iis-60-to-iis-7-or-above

https://blogs.iis.net/bills/how-to-migrate-from-iis-6-to-iis-7

Comments

  • Anonymous
    May 12, 2015
    Good one navba !!! Very useful to resolve the issue