Friday, November 18, 2016

Step by step backup and Restore WSP Custom Web Part\Solutions files in SharePoint 2013

 Method 1.  By using SharePoint central administration

Backup Steps

1.      Central Administration--> Backup and Restore

2.      Click Perform a backup.

3.      Step 1 of 2: Select the Solutions from the list of components

4.      Click Next

5.      Step 2 of 2: Select Backup Type Full

6.      Provide Location path for Backup

7.      Click Start Backup

Restore Steps

1.      Central Administration--> Backup and Restore

2.      Click Restore from a backup

3.      Step 1 of 3: Select Backup to Restore page, from the list of backups

4.      Step 2 of 3: Select Component to Restore page, select the check box that is next to the Solution, and then click Next.

5.      Step 3 of 3: Select Restore Options page, in the Restore Component section

6.      Restore Options section, under Type of Restore, select the Same configuration option

7.      Provide Backup Directory Location path

8.      Click OK

9.      Click Start Restore.

Method 2.  By using  Power Shell

Backup Steps

1. Open SharePoint 2013 Management Shell.

2. Run the following Shell to export all the SharePoint 2013 .WSP File

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

 ## set output directory

$dirName = "C:\ BackupSolutions"

Write-Host Exporting solutions to $dirName

foreach ($solution in Get-SPSolution)

{

    $id = $Solution.SolutionID

    $title = $Solution.Name

    $filename = $Solution.SolutionFile.Name

     Write-Host "Exporting ‘$title’ to …\$filename" -nonewline

    try {

        $solution.SolutionFile.SaveAs("$dirName\$filename")

        Write-Host " – done" -foreground green

    }

    catch

    {

        Write-Host " – error : $_" -foreground red

    }

}

Restore Steps

Run the below Power Shell to import/add all the SharePoint 2013 .WSP File

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

## set input directory

$dirName = "C:\BackupSolutions"

 Write-Host Importing solutions from $dirName

$fileEntries = [IO.Directory]::GetFiles($dirName);

$list = Get-ChildItem $dirName | where {$_.extension -eq ".wsp"}

foreach($fileName in $fileEntries)

{

    try

    {

        Add-SPSolution -LiteralPath $fileName;

        Write-Host " – done" -foreground green    

    }

    catch

    {

        Write-Host " – error : $_" -foreground red

    }

}

 

foreach ($s in Get-SPSolution)

{

if(($s -ne $null) -and ($s.ContainsWebApplicationResource))

 {

 Install-SPSolution -Identity $s –AllwebApplications -GACDeployment

 }

 else

 {

 Install-SPSolution -Identity $s -GACDeployment

 }

while ($s.Deployed -eq $false)

 {

     Start-Sleep 2

 }

 }

 

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist

Step by step backup and Restore Site Collection in SharePoint 2013 Step by step backup and Restore Global Assembly Cache (GAC) in SharePoint 2013

No comments:

Post a Comment