move site collection to dedicate content database

We have to move site collection to dedicate content database when content database size growing too large. One content database present under a web application in SharePoint contains multiple site collections. We can create or add new content databases under web application when limit of maximum number of sites that can be created in this database exceed while creating new site collection. If one site collection present under a content database is growing large, user request to create a dedicate content database and move that particular site collection to another new content database. We need to follow the steps as described below to move site collection to dedicate content database.

  1. Get site collection GUID using powershell
  2. Get which content database site collection web application is stored
  3. Create new content database in SharePoint
  4. move site collection to different content database
  5. IISRESET SharePoint server
  6. Post Implementation testing

Get site collection GUID using powershell

Before you move site collection to another content database, get guid of sharepoint site. You can get site collection guid using powershell script as mentioned below.

$site=Get-SPSite http://win-q2repghf9du/sites/TeamSiteClassicRenamed
$siteguid=$site.id
echo $siteguid
get site collection guid powershell

Get which content database site collection web application is stored

Get site collection content database details including web application, site url using the powershell command below.

Get-SPSite | Where-Object {$_.Url -like "http://win-q2repghf9du/sites/TeamSiteClassicRenamed"} | select Url, ContentDatabase, WebApplication
content database in which site collection is stored

You can use the alternative command as described in my old post link below.

content database in sharepoint

Create new content database in SharePoint

I described in detail about how to create or add a new content database in SharePoint in my previous post. Follow the post linked below for more details and use the powershell script for creating content database.

create add a content database in sharepoint 2019
New-SPContentDatabase "WSS_Content_DB2" -DatabaseServer "WIN-Q2REPGHF9DU" -WebApplication http://win-q2repghf9du/ -MaxSiteCount 1 -WarningSiteCount 0
Create new content database in sharepoint using powershell
Content database in sql server

move site collection to different content database

Now we are ready to move site collections between databases using the powershell command Move-SPSite as described below.

Move-SPSite "http://win-q2repghf9du/sites/TeamSiteClassicRenamed" -DestinationDatabase "WSS_Content_DB2"
move site collection to dedicate content database

IISRESET SharePoint server

You will get a message in powershell window like “IIS must be restarted before this change will take effect. To restart IIS, open a command prompt window and type iisreset”. You have to do IIS reset SharePoint server.

iisreset
iisreset sharepoint server

Post Implementation testing

After move site collection to new content database completed, you can check GUID of the site collection again. Its same as source location.

check guid of site in sharepoint

check content database of site collection to cross check the new content database as destination location.

check content database of site collection



Categories: administration, content databases, Migration, powershell command, powershell script, SharePoint 2019, sharepoint server, site collection

Tags: , , , , , , , , , , , , , ,