Split Sharepoint Content Database

536 Views Asked by At

I have a single SharePoint content database (Sharepoint 2019 - On Premise) that is over 100 GB and I would like to split the SP sites between some new content databases that I will make.

I have created the new content databases but I have no idea on how to move the subsites to them.

Based on research that I have done, it seems I need to:

  • Create Content Databases
  • Create site collections in those databases
  • Move sub collections into new site collections in the new databases.

Question 1 - are the above steps correct or do I have this wrong?

Question 2 - How in the heck do I move subsites out of the almost full content database, into new content Database? Do I move it to the site collection in the new database? If so How?!?

Thankyou for your brainpower and help

Tried moving subsites and failed

1

There are 1 best solutions below

0
On

Unfortunately, I could not understand if you wish to transfer just some subsites or a complete site collection, so I will list below both of these ways.

I would strongly suggest that you create a sandbox environment before proceeding with any of the below scripts, just in case you have misunderstood anything.

Before any transfers are performed, you should create the Content Databases that you will be targeting. You can perform such task either via the Central Admin Panel (GUI) or via a PowerShell Script, of which the command would be the below:

#get web app under which you will create the content db.
$WebApp = Get-SPWebApplication 
#create the new content database
New-SPContentDatabase "<Name_of_new_Content_db>" -DatabaseServer "<db_server>" -WebApplication $WebApp
#you can also use the below parchment which points directly to the web app.
#New-SPContentDatabase "<Name_of_new_Content_db>" -DatabaseServer "<db_server>" -WebApplication http://web-app/

In case you wish to transfer whole site collections or clone them on to different Content Databases there are three ways to achieve this.

  1. Copy Site Collection, use the Copy-SPSite cmdlet to make a copy of a site collection from an implied source content database to a specified destination content database. The copy of the site collection has a new URL and a new SiteID.

    Copy-SPSite http://web-app/sites/original -DestinationDatabase <Name_of_new_Content_db> -TargetUrl http://web-app/sites/copyfromoriginal

  2. Move Site Collection, the Move-SPSite cmdlet moves the data in the specified site collection from its current content database to the content database specified by the DestinationDatabase parameter. A no-access lock is applied to the site collection to prevent users from altering data within the site collection while the move is taking place. Once the move is complete, the site collection is returned to its original lock state. The original URL is preserved, in contrast with Copy-SPSite where you generate a new one. As you can see, before executing the below script each content database was hosting at least one site collection. enter image description here

    Move-SPSite http://web-app/sites/originalbeforemove -DestinationDatabase <Name_of_new_Content_db>

After the execution, you can see that a site was transfered from the last content database to the second, preserving its original url. enter image description here

  1. Backup and Restore Site Collection, this combination will save the site collection on the disk and afterwards restore it onto a new Content Database. The Restore-SPSite cmdlet performs a restoration of the site collection to a location specified by the Identity parameter. A content database may only contain one copy of a site collection. If a site collection is backed up and restored to a different URL location within the same Web application, an additional content database must be available to hold the restored copy of the site collection.

    Backup-SPSite http://web-app/sites/original -Path C:\Backup\original.bak

    Restore-SPSite http://web-app/sites/originalrestored -Path C:\Backup\original.bak -ContentDatabase <Name_of_new_Content_db>

Once I executed the above commands, a new site was restored on the third Content Database, which was basically a clone of the original site. Keep in mind, that with this path you will preserve the original site and will be able to work on the newly restored copy. enter image description here


In case you wish to transfer just one Sub Site on to a different Content Databases you can follow the below strategy.

  1. Use the -Force flag in case of the below error.

File C:\Backup\export.cmp already exists. To overwrite the existing file use the -Force parameter.

  1. You can import sites only into sites that are based on same template as the exported site. This is refering to the Site Collection and not the SubSite

Import-SPWeb : Cannot import site. The exported site is based on the template STS#3 but the destination site is based on the template STS#0. You can import sites only into sites that are based on same template as the exported site.

#Create Site Collection in targeted Content Database first
New-SPSite http://web-app/sites/subsiterestoration2 -OwnerAlias "DOMAIN\user" -Language 1033 -Template STS#3 -ContentDatabase <Name_of_new_Content_db>
#export Web object, use force to overwrite the .cmp file
Export-SPWeb http://web-app/sites/original/subsitetomove -Path "C:\Backup\export.cmp" -Force
#Create a new Web under the new Site Collection, although it is not necessary and you can always restore on to the RootWeb. I created the new Web object just to preserve the previous architecture.
New-SPWeb http://web-app/sites/subsiterestoration2/subsitemoved -Template "STS#3"
#Finally, import the exported Web Object on to the Targeted Web
Import-SPWeb http://web-app/sites/subsiterestoration2/subsitemoved -Path "C:\Backup\export.cmp" -UpdateVersions Overwrite

Final Notes

Keep in mind that all of the transfers were performed on sites that did not have any kind of customizations upon them, like Nintex WFs or custom event receivers. These were just plain sites that several Lists and Document Libraries.

Always make sure that once you are performing the below tasks that the Users are not altering data that currently exist within the site collections in question.

To briefly answer your question, yes you have the correct idea of what there is to be done in case you wish to transfer just the a sub site, but you must pick the best method of the above that suits you.

Always pay attention that most of the methods alter the url which points to a subsite, which you should be cautious about if any other third party automations are getting and updating data on Sharepoint with these urls.

I will try to keep this answer updated with the ways of transfering a subsite, in case anything else comes up.