Thursday, January 20, 2011

Export & Import SharePoint Site, Library & Lists using PowerShell

If you want to take backup of your SharePoint Site, Library and List… there are several methods available. The more common methods include:

1.SharePoint Central Admin.

2.Command Line Utility

a. PowerShell.

b. STSADM

Here we will discuss how we can do it using PowerShell.
First, let me tell you about PowerShell. PowerShell is new tool that consists of a command line shell and associated scripting language. Similar to DOS in its use of a command line interface, PowerShell is more powerful than other command line shell. With PowerShell you can run a single command as well as batch file commands. If you know DOS then the good news is that you can use some of the same DOS commands on PowerShell. Microsoft highly recommends use PowerShell. Why so? Theory behind this is: You can’t manage SharePoint 2010 completely without using PowerShell. STSADM commands can get you most of the things done and are useful for migration but not all.

Here are some tips for using PowerShell:
1.Get list of all PowerShell commands : Get-Command
2.Get help of any PowerShell command: Get-Help "Command Name" or "Command Name" -?

Let’s move to our main topic: how to use PowerShell to Export & Import SharePoint 2010 objects.
In this example we are creating one site with a list and library.

First, we add a blank site to the site collection.
Now, follow the steps below to open the PowerShell command interface on your system.
1. On the Start menu, click All Programs.
2. Click Microsoft SharePoint 2010 Products.
3. Click SharePoint 2010 Management Shell.
4. Your screen will look like


Take a look at the TechNet article, Add-SPShellAdmin, for a list of minimum requirements needed to run the PowerShell command.
5. Now run this command for Export:
Export-SPWeb -Identity "Site URL / GUID" -Path "Path and file name"

6. It will create two files on specified location.

Your site is now exported :)

The Export –SPWeb command includes several options for exporting sites, lists and libraries. For more information, read the article Export -SPWeb on TechNet.

Now, let’s create a new site in the SharePoint environment by importing the site we exported in the previous steps. It is important to create the new site using the same template; otherwise, the process will generate an exception during the import.
1. Open PowerShell.
2. Now run this command for Import
Import-SPWeb -Identity "Site URL / GUID" -Path "Export file name"
If you want to overwrite existing site use “-Force” option.
The Import –SPWeb command also includes several options for importing sites, lists and libraries. For more information, read the TechNet article: Import-SPWeb
3. Now your new site will look the same as your source site.

4. It will create one file for the import log.

Now eNjoy :)

1 comment:

  1. Hi very nice post and i have gain lot of information from this article and i am also sharing the new information with you people IIEIM The executives of today need to constantly evolve and understand the needs of the international market. An ability to understand, strategic, plan and execute ideas and knowledge is primary for success. Import and Export

    ReplyDelete