Share and Enjoy !

Yesterday Kirk needed to have several instances of the same site collection available in a SharePoint farm. The purpose was to have the same SharePoint content available and then manually configuring each slightly differently for testing purposes. Learn more about how he did this.

In this case I was doing some automated testing against different instances of Confluence for the SharePoint Connector for Confluence and wanted a different SharePoint site collection for each.

I manually created a site collection just the way I wanted it. In this case the site collection URL was http://csisp/sites/test26 (going against a 2.6 version of Confluence) so I’m using the standard “sites” wildcard managed path. I created a backup of the site collection. Then my next inclination was to create an empty site collection for my next site and simply restore the backup there. If you try that, you’ll get the following error:

No content databases are available for this operation. Create a content database, and then try the operation again. To create a content database, click "Content databases" on the Application Management page, select the Web application to use, and then click "Add a content database".

After it fails, your site collection will be gone.

With a little searching I found several blogs on this, such as Robert Bogue’s blog and Ryan McIntyre’s blog. Some information you may find will basically say that you need to delete your original site collection first. I didn’t want to do this, however, since I wanted several nearly identical environments available at the same time. Other blogs will give you a little more information, but I didn’t see any that went into much detail, so I’ll try to provide some more here.

The issue is that a site collection backup has GUIDs in it that must be unique for the content database in which it is stored. The simple solution is to create a content database per site collection. Here is how to do this:

First create your site collection backup using a command such as:

stsadm -o backup -url http://csisp/sites/test26 -filename C:\csiTestSpBackup.bak

For each restoration of the backup do the following:

  • Create a new content database within your target web application. Go to Central Admin -> Application Management -> Content Databases. Make sure you have your web application set properly. When setting the name of the content database, I recommend modifying it slightly so that it is more readable (remove the GUID and put something else there).

  • Create your new site collection. Outside of the URL, most settings of this site collection don’t matter since they will be overwritten by your restoration (next step). The new site collection should use your new content database, but it’s not entirely clear what the algorithm is. You can check if it did by going back to the “Content databases” link and looking at the “Current Number of Sites” column (it really means site collections, not sites). A way to ensure that it goes to your new content database may be to modify all others to be “Offline” (which appears to mean that they can be used but do not accept any new site collections) or to modify the “Maximum Number of Sites” to 1.

  • Restore your site collection backup to your new site collection URL.

stsadm -o restore -url http://csisp/sites/test29 -filename C:\csiTestSpBackup.bak -overwrite

Share and Enjoy !

Related Content: