SharePoint Backup and Restore

By:   |   Comments   |   Related: > SharePoint


Problem

How important is backup and restore in SharePoint? As a SharePoint administrator or developer, you might already know it is something which happens almost every day in a busy SharePoint farm. For example, a user might delete a document or a library, the site might get deleted or corrupted or simply users need a copy of a site in a lower environment (UAT or Development).

Solution

In this article, I will discuss backup and restore methods in SharePoint. I will be also be discussing real time scenarios. First, I will write about the common types of backup and restore in SharePoint and then I will write about real time scenarios in a busy SharePoint farm.

Common Types of Backup-Restore in SharePoint

Backup Site Collection

The following PowerShell command will create a backup and save the file to the given path.

Backup-SPSite –Identity http://Servername/sites/site1 –Path "D:\Site1.bak"

Restore Site Collection

The following PowerShell command will restore the site collection. Make sure to provide the right content database name where you want to save this site collection.

Restore-SPSite –Identity http://Servername/sites/site2 -Path "D:\Site1.bak" –DatabaseServer "DatabaseServerName" –DatabaseName "ContentDatabaseName" - Force

Export Subsite

Export-SPWeb http://Servername/sites/site1/subsite1 –Path "D:\Export.cmp"

Import Subsite

Import-SPWeb http://Servername/sites/site1/subsite12 –Path "D:\Export.cmp"

Item-level Backup Restore

Item-level recovery allows the recovery of single or multiple items in a SharePoint site. For example, if a user mistakenly deleted a production document library and it’s not found in the Recycling bin, then how we can recover it? First, we will need to get the content database back up from the file from the day the document was deleted; mount it in a lower environment web application, export the deleted document library and then import back to the production site. Following are the PowerShell commands:

Export-SPWeb –Identity http://servername/sites/site1 –Path "D:\library.cmp" –ItemURL "http://servername/sites/site1/library.aspx"
Import-SPWeb –Identity http://Servername/sites/site2 –Path "D:\library.cmp"

Recover SharePoint Data from an Unattached content Database

This is a very useful method to recover data without mounting the database to a web application. I wanted to include this method as I haven’t seen many SharePoint Administrators using this brilliant backup feature. Basically, we recover content directly from the content database without attaching it to a web application. It is extremely useful when an organization does not have enough server resources (or it will compromise server performance) to create a special web application just to recover data. Following are the steps:

Go to SharePoint central Administration > Backup and Restore > Recover data from an unattached content database.

sharepoint backup and restore

In this example, we will use "Backup site collection". By using this method, we can also backup subsites and any SharePoint content from the content database.

sharepoint backup and restore

Next step will be to select a site collection, save a backup file to a specified location and start the backup.

sharepoint backup and restore

You can always check the backup job status on the "Granular backup job status" page. Once the site collection backup is complete, we can restore it by using the previously explained "Restore-SPSite" PowerShell command.

How to Resolve Real-time Backup and Restore Scenarios

Backup and Restore site collection over 100GB in size

According to Microsoft’s guidelines, SharePoint site collection backup and restore is only supported for a maximum size of 100GB. This is one of the common real time issues that we face in a SharePoint environment.  Following are the workable methods to resolve this issue:

  1. If a site collection is the only site collection in a content database, then we can simply take a backup of that content database and restore it in the required environment.
  2. Another instance is when there are many site collections in a single content database and you need to do backup and restore of a single site collection (over 100GB in size), how will you do it? If you try to backup this site collection, the process will run forever and eventually will time out. Following are the steps:
    • Add a new content database attached to the same web application from where you are planning to back up and restore a site collection.
    • Use Move-SPSite to move the site collection to new content database. By doing this, site collection will move to the new content database.
    • Now all we need to do is take a backup of the new content database and restore wherever it’s required to be restored.

There is not enough space on the disk while exporting sites in SharePoint

For instance, if you get a request from a user to move a SharePoint subsite to a new location and while exporting (Export-SPWeb) the site, you get an error "There is not enough space on the disk", how will you resolve this error and do a successful export?

Usually, we get this error when a subsite is large in size (for example a 20GB subsite). Now, when you try to export a 20GB subsite in a new location (for example D:\ drive with 200 GB in size and 100 GB free space) and it shows an error "There is not enough space on the disk". What is the reason?

The reason is when you run Export-SPWeb command, it first exports the subsite’s content to the Windows TEMP folder which is mostly located on the C:\ drive and once the export operation is complete, it saves a file to the desired location (D:\ drive).

There is a good chance you might not have enough free space on the C:\ drive to export a subsite.  Following is a couple of ways to resolve this issue:

This can be resolved by changing the %Temp% folder location in the Windows environment variable (path – My Computer > Advance System Settings > Advanced > Environment Variables).

windows environment variables

Change TEMP and TMP location to the D:\ drive. Now when you run the subsite export command, the temporary content files will be first saved on the D:\ drive and you will not see the error.

windows environment variables

Another method is as simple as increasing the size of the C:\ drive. But sometimes it’s not a viable method as you might get stuck with moving a 50GB subsite to a different location. Another reason is server resources, not every organization will have enough server resources to increase the C:\ drive disk space.

Conclusion

There are various methods provided by Microsoft to use backup and restore functionality. Each and every SharePoint farm is different and you as a SharePoint administrator will need to decide which backup and restore method works better for you while restoring a site collection, subsite or a list.

Next Steps


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Deepak Kumeri Deepak Kumeri is a senior SharePoint Administrator and with experience in MOSS 2007, SharePoint 2010, 2013, 2016 and SharePoint online.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article

















get free sql tips
agree to terms