Sunday, August 19, 2012

SharePoint 2010: Split SiteCollections and ContentDB (Part 2)

So... here's a little script I wrote, maybe this will help you with splitting your SiteCollection & ContentDB. I think if you're using my last blog, you will get the code.
If you do have trouble understanding it or if you're having any questions, please feel free to comment below, I will get back at you.

Tuesday, August 7, 2012

SharePoint 2010: Split SiteCollections and ContentDB

Today, I want to write about a little problem I had. Let's say your ContentDB is getting really huge, like 150GB+,  and you need to split it, but you are only using one SiteCollection. What will you do?

Split your damn SiteCollection!
Of course SharePoint 2010 will work with a 200GB+ ContentDB. Even 4TB are possible, but their no fun when you're trying to back up that stuff. You will need a really great SharePointArchitect to keep that under control. Why would you like to do that? There's no reason. So just split your SiteCollection.

But how?
First step on this maybe-rocky-road: Make up your mind. Think about how big your pages are and how do you want to split your SiteCollection. Maybe your SiteCollection is already logically splitted by a navigation panel or whatever. Usually you have different categories which will create your navigation. Using this is usually a really good start. Check your sites, maybe some of them are already huge, like 25 -50gb or even more. For those pages I would recommend an own ContentDB.

Create new ContentDBs!
Let's assume we now know in which categories we want to split our SiteCollection. Now we need to head over to the Central Administration. Click at "Application Management" and choose "Manage content databases".

Here you can create your new content database. Think about the database name and choose a smart one. You don't want to have hundreds of "WSS_Content_XX" databases.

Create a new SiteCollection!
Again we do this in our Central Administration. And again you will find this option under "Application Management".
Again choose a smart name.

Export your Site. Please.
There are a couple of ways to do this. Of course you can copy all your files by hand. That's one of the ways I don't like. So we just take the easiest way: Export-SPWeb. Just run this command in your PowerShell-Tool.
Export-SPWeb -Identity WEB -Path SAVE -IncludeUserSecurity -IncludeVersions all -NoFileCompression -Force
WEB = This is the identity of the web / site / list / item you want to export
SAVE = This is where you want to save your back up
-IncludeUserSecurity = Include Usergroups and Site Permissions
-IncludeVersions all = Include all Versions of your site, list, or document library
-NoFileCompression = Decide if the back up file is compressed or not. If you choose not to, you will get a folder and of course the size is bigger than the compressed version.

Import me baby!
This can get a bit troubling at times, depending on your farm. If you have some special features activated, you need to do the same on the new target site. Also if you are using a different theme, you have to choose this first. If you have some features, you can script the activation too.
Enable-SPFeature -Identity GUID -Url TARGETSITE
 Now we can import our back up.
Import-SPWeb -Identity TARGETSITE -Path SAVE -Force -NoFileCompression
TARGETSITE = This is the Site, where you want to import your backup
SAVE = This is where you saved your backup

Split your Database!
Maybe you remember that you created a new ContentDB at the beginning. Now it's time to use it. We will move our SiteCollection via PowerShell to it's new home!
Move-SPSite SITE -DestinationDatabase CONTENTDB
 SITE = The site you want to move.
CONTENTDB = your destination database
Make sure that the ContentDB is on the same server!

And that's it! Now you have a couple of SiteCollections instead of one huge and you can move them to different ContentDBs. Not that hard, right?

Well, I had some problems which I will address (including an example-script) in my next post, so stay tuned for more information on export, import, moving and those little funny workflows and templates.