locked
Backup or export/import of site objects RRS feed

  • Question

  • Hi All,

    I'm trying to achieve the ability to copy or move document libraries or lists from one site collection to the other. Though I have check online and it seems to suggest that and import/export will do it, it does not seems to work. My problems seems to be the syntax for specifying where the library is.Please can you help. Also, is a backup/restore option for document libraries.

    Thanks,

    Dominic

    Wednesday, June 1, 2016 5:36 PM

Answers

  • HI,

    Here is a basic example of performing library or List export and further import using PS1.

    First, export:

    Export-SPWeb  -Identity http://sitename.domainname.com -Url /Library_Name -path “c:/Library_Name_Backup.cmp”

    Or

    Export-SPWeb -Identity “http://sp.dev/subsite” -ItemUrl “/subsite/lists/List Title here” -path “c:\temp\tempfile.txt”

    -Identity: full url (absolute) of the site where the list exists -ItemUrl:  relative path of the list from subsite level. Do not forget to include the leading “/” -path: path of the output file to save the data in. This does not need any extension but I usually give it .txt or CMP that stands for Content migration package there are lot more additional parameters but above are the minimum for copying a list

    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

    ItemUrl - Here we have to pass the url of the list or library. For example for a list it may be like "/lists/mylist". Note: For libraries it will be like "/LibraryName" without "/lists/". You can get this from the url of the list in the browser.

    here you can also migrate your list /library using Save List/Library as temple option as well or can do using Powershell as well as 

    SPSite oSiteCollection = SPContext.Current.Site;
    SPList oList = oSiteCollection.AllWebs["Site_Name"].Lists["List_Title"];
    oList.SaveAsTemplate("File_Name.stp", "List_Template_Title", 
    "Description", true);


    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful



    • Edited by KRISHANA KUMAR Wednesday, June 1, 2016 6:49 PM
    • Proposed as answer by N L V Tuesday, June 7, 2016 4:17 PM
    • Marked as answer by Hemendra Agrawal Tuesday, June 14, 2016 5:59 AM
    Wednesday, June 1, 2016 6:39 PM
  • You can run the following powershell commands -

    To Export -

    Export-SPWeb "http://yoursite/" -itemurl "/MyDocumentLibrary" -path "c:\mydoclibrary.cmp"

    To Import -

    Import-SPWeb "http://yoursite/" -path "c:\mydoclibrary.cmp"
    Reference - https://technet.microsoft.com/en-us/library/ee428293%28v=office.14%29.aspx?f=255&MSPPError=-2147217396


    NLV

    MCTS | Blog | Twitter | Linked In
    If this post helps or answers your question, "Vote" or "Mark as answer".

    Wednesday, June 1, 2016 5:59 PM

All replies

  • You can run the following powershell commands -

    To Export -

    Export-SPWeb "http://yoursite/" -itemurl "/MyDocumentLibrary" -path "c:\mydoclibrary.cmp"

    To Import -

    Import-SPWeb "http://yoursite/" -path "c:\mydoclibrary.cmp"
    Reference - https://technet.microsoft.com/en-us/library/ee428293%28v=office.14%29.aspx?f=255&MSPPError=-2147217396


    NLV

    MCTS | Blog | Twitter | Linked In
    If this post helps or answers your question, "Vote" or "Mark as answer".

    Wednesday, June 1, 2016 5:59 PM
  • HI,

    Here is a basic example of performing library or List export and further import using PS1.

    First, export:

    Export-SPWeb  -Identity http://sitename.domainname.com -Url /Library_Name -path “c:/Library_Name_Backup.cmp”

    Or

    Export-SPWeb -Identity “http://sp.dev/subsite” -ItemUrl “/subsite/lists/List Title here” -path “c:\temp\tempfile.txt”

    -Identity: full url (absolute) of the site where the list exists -ItemUrl:  relative path of the list from subsite level. Do not forget to include the leading “/” -path: path of the output file to save the data in. This does not need any extension but I usually give it .txt or CMP that stands for Content migration package there are lot more additional parameters but above are the minimum for copying a list

    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

    ItemUrl - Here we have to pass the url of the list or library. For example for a list it may be like "/lists/mylist". Note: For libraries it will be like "/LibraryName" without "/lists/". You can get this from the url of the list in the browser.

    here you can also migrate your list /library using Save List/Library as temple option as well or can do using Powershell as well as 

    SPSite oSiteCollection = SPContext.Current.Site;
    SPList oList = oSiteCollection.AllWebs["Site_Name"].Lists["List_Title"];
    oList.SaveAsTemplate("File_Name.stp", "List_Template_Title", 
    "Description", true);


    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful



    • Edited by KRISHANA KUMAR Wednesday, June 1, 2016 6:49 PM
    • Proposed as answer by N L V Tuesday, June 7, 2016 4:17 PM
    • Marked as answer by Hemendra Agrawal Tuesday, June 14, 2016 5:59 AM
    Wednesday, June 1, 2016 6:39 PM
  • Hi Dominic,

    For copying or moving document libraries or lists, Export/Import is a good solution.

    You said it does not seems to work, what did you mean? Could you give the detail about your problem?

    Best Regards,

    Wendy


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Thursday, June 2, 2016 1:46 AM
  • I hope the above suggestions clarifies you concern. Moreover, you may also get help from below resources:

    How to move a document library from one site collection to another site collection in SharePoint 2010:
    http://pravahaminfo.blogspot.in/2011/05/how-to-move-document-library-from-one.html

    Also you can do a granular level backup of your document library from Central Admin -> backup and restore -> Granular backup -> Export a site or list.

    You can restore this backup to new web or site collection by using following command:
    Import-SPWeb -Identity "Web name" -Path "FilePath".

    Get in detailed about Import vs Backup for site collection. Copy SharePoint lists and document libraries from one site to another using PowerShell

    Exporting and Importing SharePoint 2010 Content:
    http://www.mssharepointtips.com/tip.asp?id=1049

    Hope this helps!


    Easily migrate anything from Office 365, File Servers, Public Folders, OneDrive and SharePoint to SharePoint Online easily with Lepide SharePoint Migrator.

    Thursday, June 2, 2016 10:36 AM
  • 
    

    Hi,

    Thanks for this. I realised that I was using the wrong syntax and got the itemurl naming convention wrong.

    Thanks for the tip.

    Dominic

    Thursday, June 2, 2016 8:52 PM
  • Hi Krishana,

    Great answer. I realised the hard way that the itemurl must be the "/Libraryname". Thanks alot for the tip. I'm now able to export and import my required libraries.

    Thanks,

    Dominic

    Thursday, June 2, 2016 8:58 PM