Thursday 10 January 2013

Exporting and Importing a Site, Library, or List using PowerShell


The SharePoint 2010 Central Administration UI is not the only way to export a site, library, or list. SharePoint 2010 provides PowerShell cmdlets to export or even to import them back whenever required. You can even script out these operations to run  manually or schedule them with the Windows Task Scheduler to make it run on a  scheduled basis.

Let's explore these cmdlets in detail.

The Export-SPWeb command is used to export a site, library, or list.

The Import-SPWeb command is used to import them back.

The general syntax of these commands are:

Export-SPWeb [-Identity]
<site-url> -Path<filename-&-location> [-Force] [–IncludeUserSecurity][-ItemUrl <List-or-Library-Name>]

Examples:
//Export site collection
Export-SPWeb -Identity http://site -Path E:\ Backup\sitename.cmp –Verbose
//Export Site Pages From particular site
Export-SPWeb -Identity http://site -Path E:\ Backup\sitename.cmp -ItemURL "Site Pages" –Force
//Export site with single backup file
Export-SPWeb http://site -Path E:\Backup\sitename.cmp -CompressionSize 1000 -Force –Verbose

Import Syntax:
Import-SPWeb [-Identity]
<site-url> -Path<filename-&-location> [-Force] [–IncludeUserSecurity][-Confirm]

Examples:
//Export site collection
Import-SPWeb -Identity http://site -Path E:\ Backup\sitename.cmp –Force  –Verbose
//Export Site Pages From particular site
Import-SPWeb -Identity http://site -Path E:\ Backup\sitename.cmp -ItemURL "Site Pages" –Force

2 comments:

  1. Wow... thank you for reposting stuff found in the built-in help file and clogging up the Internet with useless search hits.

    ReplyDelete
  2. it serves as an easy look up! Am not complaining.. It helped me achieve the task.

    ReplyDelete