How to copy/clone IIS7 website on local server?

I have an existing IIS7 website that I would like to clone and have it be on the same local server. So I would have 2 identical sites that have different Site IDs (running off different IPs/ports).
I've tried to export the shared configuration & import, but that only replaces the current sites instead of adding a new one (even if I change the existing Site ID before the import). I've also seen suggestions to modify the \windows\system32\inetsrv\config\applicationHost.config file, but I'm not familiar enough w/ the file to make the appropriate changes.

Any help would be appreciated. Thanks.
mlhdAsked:
Who is Participating?
 
Brad HoweDevOps ManagerCommented:
Hi,

You are correct, you can do this simply my stop IIS Services and modifying the %windir%\system32\inetsrv\applicaitonhost.config file.

Backup existing applicationhost.config

1. Open CMD
2. %windir%\system32\inetsrv\appcmd.exe add backup "PRE-CLONE-BACKUP"

Clone Site
1. open NOTEPAD as "RUN AS ADMINISTRATOR" context.
2. FILE | OPEN %windir%\system32\inetsrv\applicationhost.config
3. Search for <Sites>
   - Here you will see something similar to below.

        <sites>
            <site name="My Site X" id="2321" serverAutoStart="true">
                <application path="/" applicationPool="test">
                    <virtualDirectory path="/" physicalPath="D:\inetpub\wwwroot" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:80:" />
                </bindings>
            </site>
            <siteDefaults>
                <logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
                <traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
            </siteDefaults>
            <applicationDefaults applicationPool="DefaultAppPool" />
            <virtualDirectoryDefaults allowSubDirConfig="true" />
        </sites>

4. Find you site config, Copy and modify. You only need the <site> </site> section.

            <site name="CLONE - My Site X" id="2322" serverAutoStart="true">
                <application path="/" applicationPool="test">
                    <virtualDirectory path="/" physicalPath="D:\inetpub\wwwroot2" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:8080:" />
                </bindings>
            </site>

5. Start IIS Services and verify.

New site should be up and running now under http://server.ip.addr:8080

If required
To restore that backup, run this command:
%windir%\system32\inetsrv\appcmd.exe restore backup "PRE-CLONE-BACKUP"

Cheers,
Hades666
0
 
mlhdAuthor Commented:
Thank you! This solution worked for us.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.