Answered by:
Need to Clone and Entire Web Application Within a Farm

Question
-
First please let me clarify that I am not an experienced SharePoint Administrator. I have only been working with SharePoint for six months now. I am an experienced web developer having worked with classic ASP and ASP.net for well over fifteen years now. I was placed in the role of SharePoint Administrator overseeing three SharePoint farms. Two running SharePoint 2010 and one (soon to be upgraded) SharePoint 2007 farm
I need to clone an entire web application, content and all, within the same SharePoint 2010 farm. Basically I have a site being used by one group that another group has seen and want's a copy of for their own use. They like the layout and all of the functionality. We have decided to make an exact duplicate, then change out a few images. get rid of whatever documents and user contributed things that shouldn't be there and then open it up to the new group. Seems simple enough and I find it hard to believe that this doesn't happen on a somewhat regular basis. I have spent a lot of time searching the web for a good approach to doing this but have so far come up empty. Frankly I find it had to believe that there is no "Copy Web Application" functionality in Central Admin or SharePoint Designer (perhaps there is and I have yet to find it). I have come across all sorts of ways to backup and restore on different servers and farms and using export and import to a different farm but nothing specific to making a copy of a site/web application within a farm.
Any and all ideas would be greatly appreciated.
Thanks, Doug
Doug Carr
Tuesday, July 2, 2013 3:43 PM
Answers
-
First, backup and restore the content database(s) to a new name within SQL Server. Next, create a new Web Application. Finally, run:
Mount-SPContentDatabase DatabaseName -WebApplication http://newWebAppUrl -AssignNewDatabaseId
That will restore the content of the Web Application. Web Application settings will need to be manually created (User Policies, Auth settings, etc).
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
- Marked as answer by Emir Liu Thursday, July 11, 2013 8:48 AM
Tuesday, July 2, 2013 4:51 PM
All replies
-
First, backup and restore the content database(s) to a new name within SQL Server. Next, create a new Web Application. Finally, run:
Mount-SPContentDatabase DatabaseName -WebApplication http://newWebAppUrl -AssignNewDatabaseId
That will restore the content of the Web Application. Web Application settings will need to be manually created (User Policies, Auth settings, etc).
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
- Marked as answer by Emir Liu Thursday, July 11, 2013 8:48 AM
Tuesday, July 2, 2013 4:51 PM -
Thanks Trevor, for your response. I was able to do this but the site still shows the old content.
I used SQL Server to create a copy of the content database from the site I want to duplicate. I created a new SharePoint Site. I then ran the Mount-SPContentDatabase as you suggested. All of these completed without any errors. When I look at the new site it looks exactly as it did before. The only thing different that I see is the second database now shows up in Central Admin for the site. The list for the new site now contains two content databases. The one that SharePoint created when I created the site and the copy of the DB that I made. What did I miss? Should I have specified the existing (copy of the DB that I made) when creating the new site?
Thanks,
DougDoug Carr
Tuesday, July 9, 2013 3:00 PM -
I'm unsure as to what you're expecting. Since you're cloning the Web Application (sans URL), you'll see the same content on the new Web Application (URL) that you see on the old web Application.
Or did you attach the copied content database to the existing Web Application?
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
Wednesday, July 10, 2013 12:21 AM -
I expected to see the same content that I would see in the source web application. What I see is the content from the new web application. The new SharePoint web application.
Here's what I did.
I made a backup of my source web applications's (WASource) content database. We'll call it WASource_DB. I then restored the backup to a new database. We'll call that WADest_DB. At this point I have two identical content databases. I then created a new SharePoint web application (WANew) which created yet another content database. We'll call that one WANew_DB. At this point I have two SharePoint web applications (WASource and WANew) and three content databases (WASource_DB, WADest_DB and WANew_DB). I then ran the mount PowerShell command to mount the copy of the source database (WADest_DB) to the new web application (WANew)
Mount-SPContentDatabase WADest_DB -WebApplication http://WANewURL -AssignNewDatabaseId
At this point I had hoped to see that the new web application (WANew) would look exactly like the source web application (WASource). Instead it continues to look like it did before running the mount PowerShell command. Its just that now it shows two content databases listed in the Manage Content Databases page for the new web application. WANew_DB and WADest_DB.
I then found a post that showed me how to remove the original content database (WANew_DB) from the new web application. Now the new web application shows the correct content database (WADest_DB). Unfortunately that broke the web application and now it won't load anything.
One issue that I see is that the "Current Number of Site Collections" listed for the copy of the source database (WADest_DB) shows "0". When I am expecting it to show "1"
I am wondering if I have done something out of order. Do I need to remove the original content database from the new web application before mounting the copied database?
I have been pulling my hair out on this project for way too long for something that seems like it should be a simple process. I have hit errors at every turn. You have gotten me closer than I have ever been. I truly appreciate your help so far and will be sincerely grateful for any additional help.
Thanks,
Doug
Doug Carr
- Edited by Doug Carr Wednesday, July 10, 2013 1:42 PM Corrected grammar mistakes
Wednesday, July 10, 2013 1:41 PM -
Yep you're right, and what you're going to have to do at this point is export the site and import it to a target (Export-SPWeb/Import-SPWeb) in order for the site to have a new GUID associated with it.
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
Wednesday, July 10, 2013 2:47 PM -
Well . . . I was able to export the site but I am getting an error on the import. It says: "Cannot find an SPWeb object with Id or Url : http://udp-sps-10:37114" This is the only URL that I have for the new site. I suppose it stands to reason that it can't find it because there appears to be nothing there. Of course it also stands to reason that this would be the way to get the site in there. Not 100% sure of exactly what this error is trying to tell me and what I need to do to get around it.
Doug Carr
Wednesday, July 10, 2013 6:06 PM -
Just read another post where the person was getting the same error and then they created the new site with "the blank site template" and the import worked. Could this be the issue?
Doug Carr
UPDATE*** Just tried creating the initial site collection using the blank site template. Still getting the same error.- Edited by Doug Carr Wednesday, July 10, 2013 6:23 PM Added information
Wednesday, July 10, 2013 6:12 PM -
Yes, prior to importing a site into SharePoint using Import-SPWeb, you need to create a site in the target location using the same Site Template that the source site was created with.
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
Wednesday, July 10, 2013 6:31 PM