Welcome to MSDN Blogs Sign in | Join | Help
Import/Export and New Content Databases

Earlier this evening, there was a discussion on an internal discussion list about the best way to cut a subsite out of a site collection and make it into a separate site collection in a separate database.  We went back and forth and I finally suggested an option using STSADM from the command line.  Now you need to understand that while this seems to work like a charm in WSSv3 (and for the purposes of this blog I will not be talking about WSSv2 or SPS 2003), there are some pitfalls to doing this in MOSS.  The main one being that this has been known to break some webs that utilize the collaboration portal or publishing portal templates (or templates created from them).  But for your regular run-of-the-mill team sites and such, this should work like a charm.

Your first step is to have a subsite.  We will say that we have a subsite located at http://server/mysubsite that we want to make into a site collection located at http://server/mynewcollection in a separate database.  We would start by exporting out the site collection to a file as such:

stsadm.exe –o export –url http://server/mysubsite -filename mysubsite.bak –includeusersecurity

Now why would we want to create a site collection in a new database?  Well…it seems that Microsoft recommends that you try to keep your content databases under 25GB if possible.  We recommend this for various reasons to include ease of backup and being able to maintain separate SLAs (service level agreements) for differing site collections (say HR or marketing).  Do we want hundreds of separate content databases?  No…of course not.  But if possible, group like collections into separate databases (say IT collections or HR collections) for ease of maintenance later. 

Since we don’t want to use the normal convention of http://server/sites/sitecollection, we are going to need to add a managed path.  We can do that through the GUI or via command line as such:

stsadm.exe –o addpath –url http://servername/mynewcollection -type explicitinclusion

We make this an explicit inclusion because we want to put the new collection directly at this point.  If we created it as a wildcard inclusion, then it would be like the /sites/ that we normally use.  So you could optionally create a wildcard inclusion for IT and the URLs would stem off as in http://server/IT/sitename.

Now we have to create the new site collection in the new database.  We do this to make a placeholder.  If we didn’t, then there would be nothing to import to in the final step.  At this point, we really don’t need to add a lot of fluff.  Just do the basics.

stsadm.exe –o createsiteinnewdb –url http://server/mynewcollection -owneremail portal@server.com –ownerlogin DOMAIN\username

This gets us most of the way there.  If you wanted to get fancy, you can always look at the syntax of the createsiteinnewdb option and notice that you could specify the database server, username and even the database name.  This could come in handy if you are a bit anal about your naming conventions like I am.  I like to see all of my content databases named as Content_xxx so they are grouped together for easy maintenance.

Our container is ready and all we have to do in import our backed up subsite into the new site collection.

stsadm.exe –o import –url http://server/mynewcollection -filename mysubsite.bak –includeusersecurity

Once this has been complete, you should be able to browse out to the new site collection.  This could also be converted into a batch file or a VBScript in a pinch.  For some of the syntax and an example of how to write a parameterized script, please see my last blog post.  There is a zip file at the end that has a lot of batch files and a script that will get you on your way.  And if that seems too difficult, you can always send me a note and I will try and help out as best as I can.

If you are trying to get the collaboration portal or publishing portal templates to export/import correctly, you should look at a post located at http://stsadm.blogspot.com/2007/09/convert-sub-site-to-site-collection.html to see how he did it.  One word of caution though.  The way he does it actually touches the database.  This particular method is not recommended by Microsoft and may put you in an unsupportable state.  I refer you to this post to see possible ways of doing something similar for education purposes only.

Posted: Wednesday, September 19, 2007 12:03 AM by stevenro
Filed under: ,

Comments

Gary Lapointe said:

Steven - regarding the convertsubsitetositecollection command that I created and the fact that it hits the database directly - I've spent several hours and spoke with a couple people at Microsoft and I've not been successful in finding a way around the problem.  The main issue is that the ContentType field get's messed up during import - it should be imported as a Choice field but it comes through as a Text field.  Unfortunately there's no way that I've been able to find using the API to either convert the field or delete and re-create it.  All the other issues can be solved using public API calls - only this one doesn't have a way that I can find.  The only solution that I just happened to think of would be to modify the Manifest.xml file before the import (not entirely sure this would work but as I can see the manifest file has the incorrect value it stands to reason that it would (only problem would be when file compression is used - I'd have to figure out how to decompress the files and then manipulate the xml file from there (either that or just don't allow file compression - of course that would also mean that I'd have to ditch the repair command as I wouldn't be able to fix anything that's already been imported).  If you or anyone within Microsoft have any suggestions as to how I can get around manipulating the database directly I'd love to hear it as this particular issue has been driving me nuts.

# September 20, 2007 10:02 PM

Kumaresh said:

I want to export one table from MS Access to Sharepoint Portal through VBScript. Is it possible to do?

# November 20, 2007 2:01 AM

Luis Du Solier G. - SharePoint en Español said:

Movimiento de bases de datos de SharePoint (distintas opciones) SharePoint Site Moves, Database Moves

# October 15, 2008 1:02 AM

SharePoint en Español - Luis Du Solier G. said:

Movimiento de bases de datos de SharePoint (distintas opciones) SharePoint Site Moves, Database Moves

# October 15, 2008 1:03 AM

SharePoint Products and Technologies - Pointing to Share the Knowledge - Luis Du Solier G. said:

Movimiento de bases de datos de SharePoint (distintas opciones) SharePoint Site Moves, Database Moves

# October 15, 2008 1:04 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker