Wednesday, May 30, 2012

IIS–migrating site settings from one server to another

Here is a simple way to migrate your sites and app-pools from one server to another (I was setting up a new dev machine for myself)

Export app-pools and sites from source machine:

%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml

%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml

Import app-pools and sites onto destination machine:

%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml

%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml

Note:

When you import the app-pool, you will need to edit the apppools.xml file to remove all those app-pools that have already been defined on your destination computer (eg: DefaultAppPool)

When you import the sites, you may get errors, just delete the sites that cause the errors and reimport the sites.xml file.

Note 2:

If you need to export only a single site use the following command:

appcmd list SITE /site.name:SITENAME /config /xml > c:\SITENAME.xml

No comments: