Restore Site Collection with new Content database to existing web application.

In one of my project, I had requirement to migrate record center site collection to the new server but in that requirement I had to create only new site collection with existing web application and different database.

So to achieve this, below is the detailed snippet of PowerShell script.

First of all I took backup of the source site collection:

Backup-SPSite –Identity http://sharepointolddev –LiteralPath "C:\Backup\olddev.bak"

Now to restore above backup into new site collection I needed to create separate content database. Below is the script to create new content database under a web application.

New-SPContentDatabase -Name "WSS_Content_DBNew" -DatabaseServer "MYDBNAME"  -WebApplication http://sharepointdev/

Once that Database is created I created empty site collection with record center site template. Below is the snippet to create new site collection with created content database.

$site = "http://sharepointdev/sites/newdev"
$dbname = Get-SPContentDatabase "WSS_Content_DBNew"
$ownerAlias = "sp\prathod";
New-SPSite -URL $site -OwnerAlias $ownerAlias -SecondaryOwnerAlias $ownerAlias -ContentDatabase $dbname -Template "OFFILE#1"

Once site collection is created I simply restored existing site collection backup with below snippet:

Restore-SPSite –Force –Identity http://sharepointdev –LiteralPath "C:\Backup\olddev.bak"

That’s it, site collection is restored with new content database in existing web application.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s