Tuesday, March 24, 2009

Create Site in New DB aka createsiteinnewdb

It almost seems like MSFT REALLY doesn't want us to create our site collections in their own databases.

First - when you are in the UI from central admin and you go to create a new site collection, it gives you NO option to specify your db name - and worse yet it just decides for you whether to just go ahead and pile this site collection on in with the database that's there or randomly create a new one.
Read this article for more detail:
http://www.networkworld.com/community/node/19780

There is a command in stsadm that makes it so you can have some nice control over the way your pile of db's ends up looking - and what site content is in which db (call me crazy but I would sort of like to know which db is storing which site's content - an not rely on some random mechanism to just decide for me- based on the size of things at the time I created the site).

ANYWAY...
So I HAD this great script which was actually VERY simple (despite the fact htat it took me days to troubleshoot because of the whole managed paths discussion)

I finally figured out how to get it to work, by having an excluded path to "hang my site collections off of" and I won't bore you with the details of that script - SINCE IT NO LONGER WORKS! The rub is that since you can no longer exclude paths using stsadm you have to trick sharepoint into allowing you to create a sitecollection in an explicit inclusion . This article helps explain why... http://pointedman.com/post/Managed-Paths-and-SharePoint-2007.aspx

My method:

1. USE THE CA GUI to
REMOVE THE ROOT PATH (this breaks the portal - so do this off hours - but don't worry we put it back in a minute)

2. USE THE CA GUI to
CREATE AN EXPLICIT INCLUSION FOR THE NEW SITE'S URL

3. USE THE COMMAND LINE STSADM UTIL to
Create the new site collection

:: Simple (creates a db called wss_content - and prompts you to pick a template and assign users when you open the site the first time)

stsadm -o createsiteinnewdb -url http://sit-portal/newsite2 -owneremail spadmin@acme.com -ownerlogin sea-spdev\dude

:: More complex (sets the db name and the template. NOTE: this creates the db - even if it fails so if you want to run it again you will have to delete the db manually)

stsadm -o createsiteinnewdb -url http://sit-portal/newsite2 -owneremail spadmin@acme.com -ownerlogin sea-spdev\dude -sitetemplate spsportal -databasename siteinnewdb2

:: Most Complex( sets all the parameters when it creates the site. Note: this is pseudocode)

stsadm -o createsiteinnewdb -url [PORTAL_URL] + [DEPT_DIRECTORY_SITE] + / + [DEPT_URL_NAME] -owneremail sp.adminatblah.com -ownerlogin na\SPAdmin -sitetemplate [CUSTOM_TEMPLATE] -title " + [Title] + " -databaseserver [DATABASE_SERVER_NAME] -databasename [DATABASE_NAME]

4. IMPORTANT - USE THE CA GUI to
ADD THE ROOT PATH back in!

Final note - if you need to MOVE stuff out of content db's after the fact read this...
http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=53

No comments:

Post a Comment