Server Level Migration with Web Deploy
This scenario is relevant when adding a new IIS server to a farm, migrating to a new server with the same version of Windows server, or migrating to a newer version of IIS and Windows server.
This method can be accomplished with either a Web Deploy package migration using the Inetmgr GUI, or the Web Deploy command line to copy the files and settings to the new server.
The -source switch for migrating an entire server is webServer.
Example Syntax:
msdeploy.exe -verb:sync -source:webServer,computername=10.0.0.11 -dest:webServer,computername=10.0.0.12
Housekeeping:
Source server = Server sending the web files
Target server = Server receiving the files (new server)
For these examples, the Source server IP is 10.0.0.11 and the Target server is 10.0.0.12.
Backup on Target Server:
As I am working with customers in either the test or production environments, I always stress the importance of taking backups on all servers BEFORE the migration to create a restore point in case issues arise during the procedure. In addition, I use the -whatif statement heavily to fix issues before the migration action.
The target server must have the Web Deploy service installed and running in order to communicate from the source server. If the service is not installed, run the Web Deploy installer again and select the Service option to install.
Make a backup of the IIS configuration settings on the target server using IIS backup and the web deploy tool to back up the web.config files:
%windir%\system32\inetsrv\appcmd add backup “PreWebDeploy”
AND
msdeploy -verb:sync -source:webServer -dest:package=c:\_WebDeploy\PreWebDeploy.zip
Note: The Appcmd utility backs up the IIS settings for the target IIS Server and the Web Deploy utility backs up the IIS settings AND the web files. An extra layer of security and a quick restore option.
Determine IIS Dependencies:
IIS dependencies between the source and target server must be reconciled to ensure the target server matches the source server for IIS features and IIS add-ons, such as URL Rewrite or ARR.
Compare Source and Target Server IIS Dependencies:
Create a directory on the C:\ drive to hold the information about the dependencies
To view the dependencies:
Obtain the dependencies from the source server by opening a command prompt and running:
msdeploy -verb:getDependencies -source:webServer > c:\_Webdeploy\SourceServerDepends.txt
Note: All commands can omit the > c:\ command and a text file is not created. The output from the command will just appear within the command window.
Obtain the dependencies from the target server by opening a command prompt and running:
msdeploy -verb:getDependencies -source:webServer;computername=10.0.0.1 > c:\_Webdeploy\TargetServerDepends.txt
Either eyeball the dependency output on the screen. Or, perform a file comparison between the output files using a tool such as Beyond Compare.
Note: The Web Deployment migration may be successful and the missing dependencies will appear as warnings. Add all IIS dependencies on the target server to ensure it matches the source server. Otherwise, there will be errors when attempting to serve a page on the target server.
Inetmgr Package Creation Method:
The easiest method is generate a package from the source server through the Inetmgr GUI and copy the package to the target server and import the package. The wizard allows for multiple different options and is easy to follow.
On the source IIS server, open Inetmgr and select the server level node in the connections pane.
In the Actions pane, select the Deploy section has the Export Server Package option to start the wizard.
Save the package on the source server and transfer to the target IIS server and repeat the process except select the Import Server or Site Package option to start the wizard.
Command Line Package Creation Method:
Verify before Execution:
Instead of the ready, shoot, aim approach, verify the Target server is ready for the package. This method generates the exact same package the GUI method explained above and provides the option to review the outcome of the migration without actually executing the actual migration by utilizing the WhatIf option.
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.exe -verb:sync -source:webServer,computername=10.0.0.11 -dest:webServer,computername=10.0.0.12 -enableLink:AppPoolExtension –verbose -whatif > c:\_WebDeploy\ServerDiff.txt
Note: The command switch -source:webServer is the equivalent to the IIS server level. This means, include everything on this IIS server in the package.
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.
Optional Compare Method:
Generate a package from Source server:
msdeploy -verb:sync -source:webserver -dest:package=c:\_WebDeploy\SourceServer.zip
Generate a package from Target server:
Msdeploy –verb:sync –source:webserver,computerName=10.0.0.12 –dest:package=c:\_WebDeploy\TargetServer.zip
Perform a Synchronization in between these two files with the –whatif and –verbose switch and send that to an output file:
Msdeploy –verb:sync –source:package=c:\_WebDeploy\TargetServer.zip –dest:package=c:\_WebDeploy\SourceServer.zip –verbose –whatif > c:\_WebDeploy\ServerDiff.txt
Generate the Package to Transfer:
From the command prompt, enter the following commands to create a Web Deploy package:
msdeploy -verb:sync -source:webserver -dest:package=c:\_WebDeploy\SourceServer.zip
Copy the package to the target server and import using the following command to test before the import:
msdeploy -verb:sync -source:c:\_WebDeploy\SourceServer.zip -dest:webServer -enableLink:AppPoolExtension –verbose -whatif > c:\_WebDeploy\SourceImportWhatIf.txt
Inspect the output in the text file by searching on Error and Warning and resolve the issues before generating the package
msdeploy -verb:sync -source:c:\_WebDeploy\SourceServer.zip -dest:webServer
Command Line Method without Packages:
This method generates a server to server transfer of IIS settings and files and the fastest method.
From the command prompt, enter the following commands to create a differencing file to review errors and warnings before generating the package file:
msdeploy.exe -verb:sync -source:webServer,computername=10.0.0.11 -dest:webServer,computername=10.0.0.12 -whatif > c:\_WebDeploy\ServerDiff.txt
Inspect the output in the text file by searching on Error and Warning and resolve the issues before generating the package:
msdeploy.exe -verb:sync -source:webServer,computername=10.0.0.11 -dest:webServer,computername=10.0.0.12 > c:\_WebDeploy\SourceToTargerServerMigration.txt
Target Server Review:
Open Inetmgr on the Target server and browse several applications to ensure execution is successful. Another blog post will list the tools and methods to troubleshoot issues with migrations.