SharePoint 2013: How to Migrate from SharePoint 2010 site with content database.
The script will migrate solutions, web parts, workflows, site templates, master pages, css, event features.
Prerequisites for Migration;
- To take the backup of existing Content database the user must have administrator rights.
- Take the backup of database in read only mode.
- Follow the steps and run the ps1 file.
Step one
Back up your content database from SharePoint 2010 Server through SQL Server 2008:
- Right-click the database of the port which you want to back up, then Tasks, and then back up...
Restore your database to the SharePoint 2013 server:
- Open SQL Server 2008 in SharePoint 2013 Server, right-click the Database node, and select Restore Database.
- Input the Database Name and select the from device radio button.
- A dialog box will appear that states that your restore was successful.
Step Two
Verify the content database missing components along with potential errors and related warnings by using PowerShell command.
Test-SPContentDatabase -name WSS_Content_DB -webapplication http://sitename
Put your all WSP of SharePoint 2010 site in to one folder and give the path location in below PowerShell ps1 file/code.
Copy all below code and put it into one file and named it as ps1 and run this file in PowerShell .The Ps1 file creates one web application and deploys multiple WSP to the newly created web application, and mount the existing database to newly created web application.
<//write-host "Create a new SharePoint Web Application”
write-host "Enter web application name"
$WebAppName = read-host
write-host "Enter port no for your web application"
$WebAppPort=read-host
write-host "Enter the application pool Name"
$WebAppAppPool=read-host
$WebAppAppPoolAccount = "System Account"
$sp = Get-SPWebApplication | Where {$_.DisplayName -eq $WebAppName}
if($sp -eq $null) {
Write-host "You can use this Web application"
$WebAppName=New-SPWebApplication -Name $WebAppName -Port $WebAppPort -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount)
}
else {
write-host "Web application is already exists "}
// deploy The WSP to Newly created Web Application.
#Location where your wsp are kept
$path = "d \.wsp"
Write-host "Please enter your Database Name:"
$global:DatabaseName = read-host
write-host "Please enter databaseserver Name:"
$global:databaseservername= read-
$list = Get-ChildItem $path | where { $_.extension -eq ".wsp" }
#Deploying of wsp
action = Read-Host "Do you want to Install WSP? (Y/N)"
if($action -eq "Y")
{
foreach($wspfile in Get-ChildItem $list)
{
$WSPFullFileName = $wspfile.FullName
$WSPFileName = $wspfile.Name
write-host "Started deploying :" + $WSPFileName;
try
{
$output = Get-SPSolution -Identity $WSPFileName -ErrorAction Stop
}
Catch
{
$DoesSolutionExists = $_
}
If (($DoesSolutionExists -like "*Cannot find an SPSolution*") -and ($output.Name -notlike "*$WSPFileName*"))
{
Try
{
Add-SPSolution "$WSPFullFileName" -Confirm:$false
$output = Get-SPSolution -Identity $WSPFileName -ErrorAction Stop
$gobal = $null
if ($output.Deployed -eq $false)
{
try
{
Install-SPSolution -Identity $WSPFileName -WebApplication $WebAppName -GACDeployment -Force -Confirm:$false -ErrorAction Stop | Out-Null
}
catch
{
$gobal = $_
}
#Check if the wsp needs to deploy globally or not
If ($gobal -like "*This solution contains*")
{
Write-Host -ForegroundColor Green "Solution requires global deployment, Deploying now"
Install-SPSolution -Identity "$WSPFileName" -GACDeployment -Force -Confirm:$false -ErrorAction Stop | Out-Null
}
}
}
Catch
{
Write-Error $_
Write-Host -ForegroundColor Red "Skipping $WSPFileName, Due to an error"
Read-Host
}
}
Write-host -ForegroundColor Yellow "Deployment Completed of” +$WSPFileName;
}
write-host "Deployed successfully"
}
#Map/Mount the database to web application
write-host "We are mounting the database"
Mount-SPContentDatabase -name $DatabaseName -webapplication $WebAppName -databaseserver $databaseservername
write-host -ForegroundColor Green "Your database is mounted successfully"
write-host "Migration is completed”
Step Three
- After successfully mounting the content database to web application, the site should be accessible in 2010 or 14 mode.
- To upgrade the site simply click on "Start now" link on the toolbar, you can also go to SiteUpgrade page from Site Setting page as well.
- Now your site collection should now be accessible in 2013 or 15 mode along with all new capabilities enabled in the farm and for the hosting web application such as Social and Office Web Apps.