Restore List From Existing In Modern SharePoint Online

Recently, we have observed that the save the list as a template option is missing for the Modern SharePoint Online site. Because of which many users are getting confused about how to restore their existing list to another site which is mostly required and quite normal in terms of SharePoint. Save as s template was a very handy option to copy list definition as well as to migrate its contents in some cases.
 
Modern SharePoint Online is missing save as a template option for the SharePoint list.
 
We restore existing lists or libraries for various reasons,
  • To restore existing list(s) into another site collection because of similar requirements for restoring list definitions
  • Sometimes, we create development and production site collection. We create several lists and libraries on the development site and then after the completion of the development task, we again retore those lists and libraries into production.
  • Sometimes, we retore the list in the same site collection with a different name to reuse the existing list and modify or use it as it is for another requirement.
  • In some cases, we might need to restore into another tenant as well if we are working with a third-party or vendor for development or some purposes.
  • In some cases, we use this option to migrate list or libraries contents
This is one of the general requirements to restore the existing list and library. Since the missing save as a template option is missing in modern SharePoint, we have some alternative ways to accomplish the same restoring of the list.
 
In this article, I will show you the different ways of restoring the list from existing in Modern SharePoint. So far, I have found 3 alternative ways
  • Option 1: Create a new list from an existing list
  • Option 2: By using PnP, save a modern list as a template and restore
  • Option 3: By enable custom script in SharePoint Online

Create a new list from the Existing list

 
This option is quite fast, easy, user friendly, and most recommended where you can create a new list from the exiting option from another site collection.
 
Firstly, we need to create a new list from Site contents as shown
 
Open Destination Site collection -> Site Contents -> Click New -> Select List
 
 
Next, we will choose an option from the existing list as shown,
 
 
After selecting, from the existing list, you will get the option to choose site collection and list within that site collection as depicted,
 
 
Select the Site collection from which you want to restore the list and the list. Then you will get the option to add the list in the current site collection as demonstrated,
 
 
You can give a name, description, and option to show in site navigation as like creating a new list.
 
This is how you can restore the existing list template.
 
However, this option has some limitations which are listed below,
  • Some lists might not be compatible which has lookup columns
  • You cannot restore data
  • Some legacy lists cannot be restored
  • Some site collections are showing incompatible lists.

By using PowerShell, Save a modern list as a template


Using PowerShell, we can save a list as the template in modern sites both in team and communication sites including list definition and data.
 
For this option, you need to have PnP PowerShell installed on your pc. Link to install GitHub – pnp/PnP-PowerShell: SharePoint PnP PowerShell CmdLets
 
You need to run following PowerShell.
  1. $siteURL = "https://YourSite/sites/SiteCollectionName"  
  2. $listName = "listName"  
  3. $templateName = "listTemplate"  
  4.   
  5. $path = “C:\Users\rijwa\Documents”  
  6. cd $path  
  7.   
  8. Connect-PnPOnline -Url $siteURL  
  9. Get-PnPProvisioningTemplate -Handlers Lists -ListsToExtract $listName -Out ("{0}.xml" -f $templateName)  
  10. Add-PnPDataRowsToProvisioningTemplate -path ("{0}.xml" -f $templateName) -List $listName -Query '<view></view>'  
Explanation
 
First, we are defining siteUrl, listName (a list which we want to save as a template), templateName, and path variables with values.
 
Then connect to SharePoint online.
  1. Connect-PnPOnline -Url $siteURL  
At last, we are extracting list and data with these commands,
  1. Get-PnPProvisioningTemplate -Handlers Lists -ListsToExtract $listName -Out ("{0}.xml" -f $templateName)  
  2. Add-PnPDataRowsToProvisioningTemplate -path ("{0}.xml" -f $templateName) -List $listName -Query '<view></view>'  
Additionally, we can add filters in data query.
 
Now, we have saved the list as a template. The second step is to add the template into the destination site collection.
 
We can achieve this by running this PowerShell.
  1. $siteURL =  " https://YourSite/sites/SiteCollectionName2"  
  2. $templateName = "listTemplate"  
  3.   
  4. $path = “C:\Users\rijwa\Documents”  
  5. cd $path  
  6.   
  7. Connect-PnPOnline -Url $siteURL  
  8.   
  9. Apply-PnPProvisioningTemplate -Path ("{0}.xml" -f $templateName  
This execution of command takes few minutes depending upon your list data.
 
After this, if we create a new list, we find this template in our site collection and we can restore the list.
 

By enabling custom script in SharePoint Online

 
Another option (not recommended) is by enabling custom scripts through SharePoint Admin Centre or PowerShell.
 
You can login to SharePoint Admin Centre -> Setting -> classic setting page.
 
 
Additionally, we can enable the specific site collection using the below PowerShell script.
  1. #Variables for SharePoint Admin Center & Site Collection URL  
  2. $AdminCenterURL = "https://site-admin.sharepoint.com/"  
  3. $SiteURL="https://site.sharepoint.com/Sites/marketing"  
  4.   
  5. #Connect to SharePoint Online  
  6. Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)  
  7.   
  8. #Disable DenyAddAndCustomizePages Flag  
  9. Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False  
Note
To apply the changes for enabling custom scripting might take up to 24 hours.
 
After enabling the custom script, we will need to go to list settings, and in the above URL, just replace listedit.aspx with savetmpl.aspx manually to save the list as a template.
 

Conclusion

 
In this article, we have learned about restoring the list from the existing one. In the modern SharePoint site, save as a template for the list and library is missing because of which users are facing issues to restore them. In this article, I have shared three alternative ways of restoring the list and library from the existing ones and take the advantages of SharePoint.