Learn how to export IIS configuration with AppCmd. Our IIS Support team is here to help you with your questions and concerns.
How to Export IIS configuration with AppCmd
Managing multiple IIS servers in a Load Balanced Environment can be difficult as it involves duplicating website configurations on each server.
Fortunately, we can make this easier by exporting configurations from one server and importing them onto others.
Furthermore, in IIS 7 or 7.5, creating a website automatically generates a unique application pool for that site.
Importantly, when transferring configurations to a second server, we have to import the associated application pools first. This supports the proper functioning of websites, as they rely on application pools, as well as a systematic import process to maintain consistency.
- How to Export the Application Pools on IIS 7
- How to import the Application Pools
- How to Export All of Our Websites
- How to Export a Package through IIS Manager
- Streamlining Application Pool Migration in IIS:
How to Export the Application Pools on IIS 7
We can export application pools on IIS 7 with the following command:
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml
This command generates an XML file (apppools.xml) that contains all application pools on the webserver. Then, we need to edit this file to exclude unnecessary applications like DefaultAppPool, Classic .NET AppPool, and SecurityTokenServiceApplicationPool.
We have to remove apppools that already exist on the second webserver, as the appcmd command does not skip existing ones. Instead, it terminates without importing any. This editing process results in a refined selection of application pools and prevents redundancy.
How to import the Application Pools
We can import the Application Pools with this command:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml
This command will create all the AppPools in the xml on the second webserver.
How to Export All of Our Websites
We can easily export our entire website with this command:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml
This command exports all the websites on our webserver. So we have to edit the sites.xml and remove the websites that we do not need to import.
We can also export a single website or application pool by adding the name of the Application Pool or Website to the command line:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml
Or
%windir%\system32\inetsrv\appcmd list apppool “MyAppPool” /config /xml > c:\myapppool.xml
How to Export a Package through IIS Manager
Before we begin, make sure you have NET Framework 2.0 SP1 or greater, Web Deployment Tool and IIS 7.0 or above, or IIS Remote Manager.
- To begin with, make a backup with the following command:
%windir%\system32\inetsrv\appcmd add backup "PreMsDeploy"
- Then, open the IIS Manager by entering inetmgr in the Run dialog box.
- Next, expand the Server node and the Sites node in the IIS Manager. Then select the Default Web Site/MyApplication option.
- Now, go to the right-hand Actions pane under Manage Packages. Then, click the “Export Application… “ option to start the wizard.
- Furthermore, the package contains the site or application we have selected and its content folders. So, we have to click the Manage Components button.
- Now, the first row is the iisapp provider entry. This is our application. We have to select the dbFullSql provider from the Provider Name drop-down in the second row. We can see a description and example path by hovering over a provider.
- Then, enter the path to the database or script file in the Path column. For example:
Data Source=.\SQLExpress;Database=MyApplicationDb;User id=MyAppUser;Password=NewPassword;
Now, we will see the database in the package contents tree view. Click Next to proceed.
- At this point, we will be able to see parameters generated as per the providers that we added in the previous step. We can names and descriptions.
- Now, choose the second parameter in the list, Parameter 2, and click the Add Parameter Entry button.
- In this example, we are creating a parameter entry that points to the connection string within the application’s Web.config file. So the parameter entry has 3 fields to be filled.
- We can select the type of parameter you want. Here, we will be selecting XmlFile as we want to point to the Web.config file.
- Then, enter the scope for the parameter entry.
- After that, we have to add a match.
- At this point, we have parameters that lets a user install this package to set the application path and change the connection string. So, click Next to continue.
- Finally, select a location to save the package.
- The wizard will handle the packaging process and then save the package to disk. After that, we can see a Summary page with an overview of all actions.
Streamlining Application Pool Migration in IIS:
Migrating multiple application pools in IIS can be difficult without the right guide. So, follow these step-by-step instructions to export and import application pools easily.
- To begin with, open an elevated command prompt and run this command:
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml
This will generate an XML file with information about our application pools.
- Next, export the configuration of the default website as seen here:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml
This command creates an XML file that captures the configuration of the default website.
- Then, move the generated XML files to the target server. Remember to edit the site value in the sites.xml file from 1 to 2 to avoid conflicts.
- Next, remove existing app pools and run these commands to import the exported configurations on the target server:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml
%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml
- We can avoid conflicts by removing the original default website and renaming the newly imported site to “Default Web Site” or another name.
- Then, open bindings and bind the old certificate to the new site to ensure a secure connection.
- Finally, carry out a check on the realms and their updated app pools. Also, review app pool permissions, especially if domain accounts are involved. We can complete the process with an IIS restart.
With the above steps, we can streamline the migration of multiple application pools in IIS, resulting in a hassle-free transfer and minimizing potential conflicts.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts demonstrated how to export IIS configuration with AppCmd.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments