在 SharePoint Server 中匯入清單或文件庫Import a list or document library in SharePoint Server

摘要: 了解如何在 SharePoint Server 2016 和 SharePoint 2013 中匯入網站、清單或文件庫。Summary: Learn how to import a site, list, or document library in SharePoint Server 2016 and SharePoint 2013.

您可以使用 PowerShell 在 SharePoint Server 中匯入網站、清單或文件庫。You can import a site, list, or document library in SharePoint Server by using PowerShell.

開始之前Before you begin

雖然您可以使用 PowerShell 或 管理中心 匯出網站、清單或文件庫,但您只能使用 PowerShell 匯入網站、清單或文件庫。如需如何匯出清單或文件庫的詳細資訊,請參閱<在 SharePoint Server 中探索網站、清單或文件庫>。Although you can use either PowerShell or Central Administration to export a site, list, or document library, you can use only PowerShell to import a site, list, or document library. For information about how to export lists or libraries, see Export sites, lists, or document libraries in SharePoint Server.

開始這項作業之前,請先檢閱下列資訊:Before you begin this operation, review the following information:

  • 您可以將匯入作為還原項目的一種方法,或是作為將項目從一個伺服器陣列移動或複製至另一個伺服器陣列的一種方法。您可以從目前的伺服器陣列、其他伺服器陣列的備份或從唯讀內容資料庫匯入網站、清單或文件庫。若要從唯讀內容資料庫匯入,您必須先附加唯讀資料庫。如需詳細資訊,請參閱<了解如何在 SharePoint Server 中附加及還原唯讀的內容資料庫>。You can use importing as a method of restoring the items, or as a method of moving or copying the items from one farm to another farm. You can import a site, list, or document library from a backup of the current farm, from a backup of another farm, or from a read-only content database. To import from a read-only content database, you must first attach the read-only database. For more information, see Attach and restore read-only content databases in SharePoint Server.

  • 您無法將從某版本 SharePoint Server 匯出的網站、清單或文件庫,匯入至其他版本的 SharePoint Server。You cannot import a site, list or document library exported from one version of SharePoint Server to another version of SharePoint Server.

在 SharePoint Server 中匯出網站、清單或文件庫Importing a site, list, or document library in SharePoint Server

您可以使用 PowerShell 手動匯入網站、清單或文件庫,或在定期執行的指令碼中執行匯入。You can use PowerShell to manually import a site, list, or document library or as part of a script that can be run regularly.

使用 PowerShell 匯入網站、清單或文件庫To import a site, list or document library by using PowerShell

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

    Import-SPWeb -Identity  <SiteURL>  -Path <ImportFileName>  [-Force] [-NoFileCompression] [-Verbose]
    

    其中:Where:

    • <網站 URL> 是您要匯入的網站 URL。<SiteURL> is the URL for the site that you are importing to.

    • <匯入檔案名稱> 是要從中匯出的檔案名稱。<ImportFileName> is the name of the file that you are exporting from.

      重要

      所匯出的網站或子網站必須具備與 Identity 指定網站之範本相符的範本。The site or subsite that you are importing must have a template that matches the template of the site specified by Identity.

      您也可以使用 Get-SPWeb Cmdlet ,並透過使用 PowerShell 管道將識別碼傳遞至 Import-SPWebPath 參數的值指定要從其匯入清單或文件庫的路徑與檔案名稱。若要讓清單或文件庫包括使用者安全性設定,請使用 IncludeUserSecurity 參數。若要覆寫指定的清單或文件庫,請使用 Force 參數。您可以使用 UpdateVersions 參數指定如何處理版本設定衝突。若要檢視此操作的程序,請使用 Verbose 參數。You can also use the Get-SPWeb cmdlet and pass the ID to Import-SPWeb by using the PowerShell pipeline. The value of the Path parameter specifies the path and file name of the file from which to import the list or library. To include the user security settings with the list or document library, use the IncludeUserSecurity parameter. To overwrite the list or library that you specified, use the Force parameter. You can use the UpdateVersions parameter to specify how versioning conflicts will be handled. To view the progress of the operation, use the Verbose parameter.

      透過 NoFileCompression 參數,您可以指定在匯入程序中不執行文件壓縮。使用此參數可使匯出和匯入程序中的資源使用狀況最多降低 30%。如果您要匯入從 管理中心 匯出的網站、清單或文件庫,或者已使用 PowerShell 匯出網站、清單或文件庫,但沒有在 NoFileCompression Cmdlet 中使用 Export-SPWeb 參數,則無法在 Import-SPWeb Cmdlet 中使用此參數。The NoFileCompression parameter lets you specify that no file compression is performed during the import process. Using this parameter can lower resource usage up to 30% during the export and import process. If you are importing a site, list, or document library that you exported from Central Administration, or if you exported a site, list, or document library by using PowerShell and you did not use the NoFileCompression parameter in the Export-SPWeb cmdlet, you cannot use this parameter in the Import-SPWeb cmdlet.

      注意

      Import-SPWeb Cmdlet 中沒有只從匯出檔案中匯入項目子集的功能。因此,匯入作業將會匯入該檔案中的所有內容。There is no facility in the Import-SPWeb cmdlet to import a subset of the items within the export file. Therefore, the import operation will import everything from the file.

如需詳細資訊,請參閱<Import-SPWeb>。For more information, see Import-SPWeb.

注意

建議您在執行命令列管理工作時使用 Windows PowerShell。Stsadm 命令列工具已過時,但為與舊版產品相容,仍會隨附提供。We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

請參閱See also

概念Concepts

在 SharePoint Server 中探索網站、清單或文件庫Export sites, lists, or document libraries in SharePoint Server