Backup SharePoint Framework solutions

SharePoint Framework is growing in a daily bases and the solutions built for it are in always evolving with new features or improvements. However, it can be necessary to restore the older solution on your SharePoint Online due to some requirements of the projects or even issues.

On SharePoint, you have a way to restore older solutions on the user interface, however, it requires some steps. I believe that the easiest way is to save an older version on your desktop prior to the update the solutions to the new version. With the PowerShell script below, you’ll save the current solutions deployed globally to your desktop. The $path will define the folder where these solutions will be stored after being downloaded. You can connect to any SharePoint site of your Tenant to get the solutions from the Tenant App Catalog. If you need to backup on the Site Collection APP Catalog, remove the line with the comment.

Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/contoso 
$appCatalog = Get-PnPTenantAppCatalogUrl
$path = "C:\Users\Contoso\Documents\BackupApps"

Connect-PnPOnline $appCatalog -UseWebLogin //REMOVE THIS LINE IF YOU NEED TO BACKUP on THE APP CATALOG ON SITE COLLECTION

$appSharePoint = Get-PnPFolderItem -FolderSiteRelativeUrl "AppCatalog"
foreach($app in $appSharePoint){
 if($app.ServerRelativeUrl -match "sppkg"){
  Write-Host "Downloading file" $app.Name -NoNewline
  Get-PnPFile -Url $app.ServerRelativeUrl -AsFile -Path $path
  Write-Host " Done" -BackgroundColor Green -ForegroundColor Black
 }
}

Conclusion

When you run the PowerShell script, you will save a solution of each SPFx (SharePoint Framework) installed on your SharePoint. Below are some references that I’ve used in this article.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *