Moving a SharePoint 2010 Site Collection to another Content Database
March 30, 2010 2 Comments
Moving a Content Database to another Site Collection has never been easier than in PowerShell. Just fire up your PowerShell, add the Snap-In for SharePoint and run Move-SPSite.
PS C:Usersmrhodes> get-help Move-SPSite -full
NAME
Move-SPSiteSYNTAX
Move-SPSite [-Identity] <SPSitePipeBind> -DestinationDatabase <SPContentDatabasePipeBind> [-AssignmentCollection <S
PAssignmentCollection>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [
-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] [-WhatIf] [-Confi
rm]PS C:Usersmrhodes> Move-SPSite -Identity http://mysharepointsite.com.au/sites/user -destinationdatabase WSS-Content-NewUserDB
Confirm
Are you sure you want to perform this action?
Performing operation "Move-SPSite" on Target "http://mysharepointsite.com.au/sites/user".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
WARNING: IIS must be restarted before this change will take effect. To restart IIS, open a command prompt window and
type iisreset.
And just that easily, my Site Collection has now been moved to a new Content Database!
Pingback: 2010 in review « Mark Rhodes
Mark,
Works great but what if I want to then move it back?…It seems that there is some cleanup that needs to be done because I get the error “Move-SPSite : Cannot insert duplicate key row in object ‘dbo.AllSites’ with unique index ‘Sites_Id’. The duplicate key value is (f3872332-d16e-4205-bd07-150f3aabadfc)”…if I look in the “from” database, the tables allsites, allwebs, and alllists still have a reference to the GUID…I am assuming that is what is throwing the error.
Tim P