Thursday, 12 July 2018

Exporting & Importing Websites and AppPoll configuration between multiple IIS instances


Export the all Application Pools
The first thing you have to do is to export/import the application pools, since they will most likely be used in your web sites and you won’t be able to import those without having their relevant app pool into place. Here’s the command-line: 
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml
This command will export all your application pools – including the default ones. You’ll need to remove those, as they will most likely be in your target IIS instance with the same name and therefore they will raise a duplicate name error, blocking the whole import. In order to avoid that, open the newly created apppools.xml  file and remove the default ones such as:
·        DefaultAppPool

·        Classic .NET AppPool

·        .NET v2.0

·        .NET v2.0 Classic

·        .NET v4.5

·        .NET v4.5 Classic

Import the Application Pools
Copy the apppools.xml  file to your target webserver and run the following command:
1
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml
Each and every Application Pool mentioned in the xml file will be created on your target IIS instance.

Export the all Websites
Open up again a command-line console on your source webserver and type in the following command:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\websites.xml
Again, you’ll have to remove the default websites –  you’ll most likely have only one default website, which is Default Website – as well as any other website you don’t want to copy and/or is already existing on the target IIS instance, otherwise the import command won’t work.

Import the Websites
Just like you did with the App Pools file, copy the websites.xml  file to your target webserver and run the following command: 
%windir%\system32\inetsrv\appcmd add site /in < c:\websites.xml

Export/Import a single App Pool or Website
These commands can also be used to export/import a single application pool or a specific website. You just have to add their identifying name to the command-line, such as:
Export a specific Application Pool
%windir%\system32\inetsrv\appcmd list apppool “CustomAppPool” /config /xml > c:\customapppool.xml
Import a specific Application Pool
%windir%\system32\inetsrv\appcmd add apppool /in < c:\customapppool.xml

Export a specific Website
%windir%\system32\inetsrv\appcmd list site “CustomWebsite” /config /xml > c:\customwebsite.xml
Import a specific Website
%windir%\system32\inetsrv\appcmd add site /in < c:\customwebsite.xml

2 Using Export configuration in IIS. 
I'd say export your server config in IIS manager:
In IIS manager, click the Server node
Go to Shared Configuration under "Management"
Click “Export Configuration”. (You can use a password if you are sending them across the internet, if you are just gonna move them via a USB key then don't sweat it.)
Move these files to your new server
administration.config
applicationHost.config
configEncKey.key 
On the new server, go back to the “Shared Configuration” section and check “Enable shared configuration.” Enter the location in physical path to these files and apply them.
 It should prompt for the encryption password (if you set it) and reset IIS.

No comments:

Post a Comment