How to export / and import SharePoint 2013 sites, lists, or libraries with PowerShell

For copying individual items across your SharePoint 2013 environments or making single item backups of  sites, lists, or libraries you may employ following PowerShell commandlets: Export-SPWeb and Import-SPWeb.

Here is a basic example of performing library export and further import using those cmdlets. First, export:

Export-SPWeb -Identity http://sitename.domainname.com -ItemUrl /Library_Name -path "c:\Library_Name_Backup.cmp"

The only thing which may cause some difficulties is how to correctly specify Identity and URL parameters, as if you are going to look at the URL of SharePoint library when it is opened in browser and try to use it – it won’t work out. Usually URL of a library accessed in browser looks similar to this:

http://yoursite.yourdomain.com/_layouts/15/start.aspx#/Your_Library_Name/Forms/AllItems.aspx

You have to take parts highlighted in bold for Export-SPWeb as a values for Identity and ItemUrl parameters including slash symbol in front of library name, otherwise it won’t work. E.g. if you omit slash in the beginning of URL parameter value Export-SPWeb will throw following (not quite self explanatory) error at you:

Export-SPWeb : <nativehr>0x80070057</nativehr><nativestack></nativestack> At line:1 char:1

So type things carefully 🙂

Next is import:

Import-SPWeb http://yoursite.yourdomain.com -Path c:\Library_Name_Backup.cmp -UpdateVersions Overwrite

Use of this 2 cmdlets will help you to create item level backups for sites, lists and libraries in SharePoint 2013. By the way for those who wondering what CMP file extension stands for – this is abbreviation for “Content Migration Package”.

And if you want to run these commands from regular PS session without starting SharePoint Management Shell be sure to load SP PS snapin using script below:

Please follow and like us:

1 thought on “How to export / and import SharePoint 2013 sites, lists, or libraries with PowerShell

  1. Craig Dennis

    Hi MikeWe’re quite new to Office 365 & Sharepoint Online. We run a modest volume of construction projects and plan to create a new sub-site for each project. Because there is a very long tail in terms of retention, we are looking to archive completed project sub-sites to a One Drive for Business account. Superficially this seems to be achievable but it seems that it may not be practical.\r\nThe sub-sites are not very sophisticated – a document library, task list, calendar, newsfeed and not a great deal more. Do you have any thoughts about this?Thanks and regards

    Reply

Leave a Reply

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