Export and Import a Subsite in SharePoint Server using PowerShell

Introduction

Subsites play a crucial role as they allow for the organization of content in a structured manner, tailored to specific team or project needs. One crucial aspect of managing them is the ability to export and import subsites, which allows you to move, backup, or replicate subsites from one location to another. In this comprehensive guide, I will walk you through the step-by-step process of exporting and importing a subsite in SharePoint, ensuring that even beginners can follow along and master this essential skill.

What is a Subsite in SharePoint?

Before we dive into the export-import process, let’s clarify what a subsite is in the context of SharePoint. A subsite is a site that is nested within a parent site, inheriting its permissions and navigation (unless you configure it, not to do!). Subsites are useful for creating a hierarchical structure within your SharePoint environment, allowing you to organize content and users based on specific projects, departments, or teams.

Why Export-Import a Subsite?

There are several reasons why you might need to export and import a subsite in SharePoint:

  1. Moving a subsite from one location to another
  2. Backing up a subsite for safekeeping
  3. Replicating a subsite structure for use in another project or team
  4. Migrating a subsite to a different SharePoint farm or environment

By mastering the export-import process, you’ll be able to handle these scenarios with ease, saving time and effort in managing your SharePoint ecosystem.

Export-Import subsite using PowerShell in SharePoint 2013/2016

How to export SharePoint subsite? To export a subsite in SharePoint 2013 using PowerShell, use the Export-SPWeb cmdlet. This cmdlet can also be used to export a subsite, list, or document library.

Open the SharePoint 2013/2016 Management Shell as SharePoint Administrator and run the following command.

Export-SPWeb -identity "https://sharepoint.company.com/sites/Sales/US/" ` 
         -Path "C:\sales-us.cmp" -IncludeVersions All -includeusersecurity

Be sure to change the URL of the site and Path values accordingly. Also, To export or import a subsite, you must have a Full Control permission level or be a Site Collection Administrator.

The Export-SPWeb cmdlet supports many switches and parameters, such as CompressionSize, UseSqlSnapshot, etc., for advanced scenarios.

Export a site, list, or document library by using the Central Administration

You can also export a Subsite from SharePoint 2010/2013/2016 Central Administration via the “Export a site or list”  capability. Go to SharePoint Central Administration >> Backup and Restore >> Click on the “Export a site or list” link under the “Granular Backup” group to start the export operation.

Export subsite sharepoint 2013 powershell

Important: Both the source and destination sites should use the same template! Also, make sure the backup location has enough space.

Import subsite in SharePoint 2016 using PowerShell

Import-SPWeb PowerShell cmdlet is used to import a sub-site from the backup. SharePoint 2016 supports creating a new subsite by importing it from the exported data (Unlike SharePoint 2013, where you’ll have to create a subsite first and then import). Use this PowerShell script to import a subsite from the template.

Import-SPWeb -identity "https://sharepoint.company.com/sites/Sales/US/" ` 
        -Path "C:\sales-us.cmp"  -includeusersecurity -UpdateVersions overwrite 

With these cmdlets, we can Export and Import a particular subsite, list, or document library. You can also use Export-SPWeb & Import-SPWeb cmdlets to copy the list with data between SharePoint Sites/Web Apps/or between different environments. For example, copy a SharePoint list from Dev to a staging server. Subsites may have dependencies, such as custom solutions or features. Make sure these are available in the destination environment.

Please note that export-import is not the same as backup-restore. Certain artifacts will not be copied during export-import. Such as:

  • Workflow association-data
  • Audit logs
  • Recycle bin items
  • Created By, Modified By details, etc.

Conclusion

Exporting and importing subsites in SharePoint is an import skill that enables you to efficiently manage, move, and replicate subsites within your SharePoint environment. By following the step-by-step guide provided in this article, you can confidently navigate the export-import process, ensuring that your subsites are easily transferable and backed up. Remember to always perform operations first in a test environment, maintain regular backups, and document your process for future reference.

Can I export a subsite with its permissions?

Yes, when using the -IncludeUserSecurity parameter in PowerShell, You can preserve the user security settings.

What are the limitations of exporting a subsite?

Some content, like running workflows or certain site collection-level features, may not be exported.

Is it possible to copy a SharePoint list from one environment to another?

Yes, you can copy a SharePoint list from one environment to another using the Export-SPWeb and Import-SPWeb cmdlets. These cmdlets allow you to copy lists with data between SharePoint Sites/Web Apps or between different environments. E.g. Here is the export process for copying a list to the temp directory:
Export-SPWeb https://sharepoint.crescent.com/Sites/Sales/ -Path "C:\Temp\ESG-Documents.cmp" -ItemURL "Documents" -IncludeUserSecurity -IncludeVersions CurrentVersion

Can I export a subsite with its content version history?

Yes, you can export a subsite along with its content version history by using the -IncludeVersions parameter with the Export-SPWeb cmdlet. Setting this parameter to “All” ensures that all versions of list items and documents are included in the export.

Can I export and import subsites in SharePoint Online?

The process of exporting and importing subsites is different in SharePoint Online. You can save a site as a template and activate the saved WSP in a blank site. Alternatively, You can use the PnP provisioning template method to export-import subsites in SharePoint Online.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

2 thoughts on “Export and Import a Subsite in SharePoint Server using PowerShell

  • I am not finding this cmdlet after installing the sharepoint module

    Reply

Leave a Reply

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