Table of Contents
Companies that completely migrate to Microsoft 365 (formerly Office 365), prefer storing all their files on SharePoint sites and document libraries. Thus, it becomes business-critical to secure this SharePoint data against data loss. We had earlier detailed native options to backup and recover a deleted Sharepoint site. However, such options are time-bound and tedious. Typically, only the entire site collection can be restored, and not a single file. Also, you will lose all changes from the time of file deletion to the point of the site’s restoration. A better native option is to backup important SharePoint files using PowerShell. We explain how you can perform Sharepoint backup and restore using PowerShell:
How To Backup Sharepoint Data and Site Collections Using PowerShell
Step #1 Set up PowerShell
Backup file operations are performed using SharePoint Patterns and Practices (PnP) PowerShell commands (SharePoint PnP). You would first need to Install the latest PowerShell version. If you do not have installed SharePoint PnP PowerShell then you will receive the below error message trying to run a PnP PowerShell script.
You can install it using these steps:
1. Run Windows PowerShell
Install-Module SharePointPnPPowerShellOnline
2. You will be asked to confirm the installation from an untrusted repository. Type “A” to proceed.
3. The installation process will start.
Once the SharePoint PnP PowerShell module is installed, the new command line will be displayed.
Step #2 Backup SharePoint Files Using PowerShell Script
Note: You must be a global administrator in Microsoft 365 (Office 365).
1. First, you must establish a connection with your Microsoft 365 (Office 365) tenant by running the command:
Connect-PnPOnline -Url https://demoppm4.sharepoint.com/sites/Intranet
where the site address should follow the “–Url”. It is https://demoppm4.sharepoint.com/sites/Intranet in