Export and Import App Pools and Websites from IIS
Export the Application Pools
First thing we need to do export the application pools.Here's the command:
%windir%\system32\inetsrv\appcmd list apppool /config /xml>c:\apppools.xml
This command will export all your application pools,including default ones.So we need to remove those because 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 below as:
- DefaultAppPool
- Classic .NET AppPool
- .NET v2.0
- .NET v2.0 Classic
- .NET v4.5
- .NET v4.5 Classic
Copy the apppools.xml file to your target web server and run the following command:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml
Export the Websites
Right after the App Pools you can copy your website configuration. Open up again a command-line console on your source web server and type in the following command:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\websites.xmlAgain we will have to remove the default websites.Most likely we have only one default website, which is Default Website.Open newly created websites.xml file and remove the Default Website
Import the Websites
Copy the websites.xml file to your target web server and run the following command:
%windir%\system32\inetsrv\appcmd add site /in < c:\websites.xml
Export and Import a single App Pool and Website
This 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.xmlExport a specific Website
%windir%\system32\inetsrv\appcmd list site "CustomWebsite" /config /xml > c:\customwebsite.xmlImport a specific Website
%windir%\system32\inetsrv\appcmd add site /in < c:\customwebsite.xml
No comments: