在 SharePoint Server 中還原自訂Restore customizations in SharePoint Server

摘要:了解如何將 SharePoint Server 2016 和 SharePoint 2013 所做的自訂還原。Summary: Learn how to restore customizations that are made to SharePoint Server 2016 and SharePoint 2013 sites.

您可以使用管理中心或 PowerShell 將所做的任何自訂還原至 SharePoint Server。所使用的還原工具會視已部署的環境類型、排程需求以及與組織所建立的服務等級協定而定。You can restore any customizations that are made to SharePoint Server by using Central Administration or PowerShell. The restore tool that you use depends on the kind of environment that you have deployed, your schedule requirements, and what service level agreements that you have made with your organization.

開始之前Before you begin

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

  • 建議您保留原始 .wsp 檔案的備份,以及用來針對信任的方案和沙箱方案建立 .wsp 檔案的原始程式碼。We recommend that you keep a backup of the original .wsp file and of the source code used to build the .wsp file for both trusted and sandboxed solutions.

還原 SharePoint Server 中的解決方案套件Restoring solution packages in SharePoint Server

用以還原方案套件的方法,由部署為「信任的方案」或「沙箱方案」所決定。The method that you use to restore solution packages is determined by whether the customizations were deployed as trusted solutions or sandboxed solutions.

「信任的方案」是由伺服器陣列管理員所部署的解決方案。其會部署至整個伺服器陣列,且可用於伺服器陣列中的所有網站。信任的方案儲存於設定資料庫中。使用 SharePoint Server 備份進行伺服器陣列備份時,信任的方案亦會進行備份,且會包含於僅有設定的備份中,同時也可單獨備份或備份為群組。還原階層中可看到這些信任的方案。Trusted solutions are solutions that farm administrators deploy. They are deployed to the complete farm, and can be used on any site within the farm. Trusted solutions are stored in the configuration database. Trusted solutions are backed up when a farm is backed up by using SharePoint Server backup, and are included in configuration-only backups, and can also be backed up as a group, or individually. They are visible in the restore hierarchy.

沙箱方案為網站集合管理員可以部署至單一網站集合的解決方案。沙箱方案儲存在與其部署所在之網站集合相關聯的內容資料庫中。沙箱方案包含在 SharePoint Server 伺服器陣列、Web 應用程式、內容資料庫及網站集合備份中,但在還原階層中看不到,且無法個別選取或還原。Sandboxed solutions are solutions that site collection administrators can deploy to a single site collection. Sandboxed solutions are stored in the content database associated with the site collection that they are deployed to. They are included in SharePoint Server farm, Web application, content database, and site collection backups, but are not visible in the restore hierarchy, and cannot be selected or restored individually.

使用管理中心還原信任的方案To restore a trusted solution by using Central Administration

  1. 確認執行此程序的使用者帳戶為 SharePoint 伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.

  2. 啟動管理中心。Start Central Administration.

  3. 在 管理中心首頁的 [備份與還原] 區段中,按一下 [從備份還原]。In Central Administration, on the home page, in the Backup and Restore section, click Restore from a backup.

  4. 在從備份還原-步驟 3 之 1: 選取備份還原] 頁面上,從清單中的備份,選取包含方案套件的備份工作並再按 [下一步。您可以依序按一下 [(+) 備份旁的檢視有關每個備份的詳細資訊。On the Restore from Backup — Step 1 of 3: Select Backup to Restore page, from the list of backups, select the backup job that contains the solution package, and then click Next. You can view more details about each backup by clicking the (+) next to the backup.

    注意

    如果未顯示正確的備份工作,在 [備份目錄位置] 文字方塊中輸入正確的備份資料夾的通用命名慣例 (UNC) 路徑] 和 [重新整理If the correct backup job does not appear, in the Backup Directory Location text box, type the Universal Naming Convention (UNC) path of the correct backup folder, and then click Refresh.

  5. 在從備份還原-步驟 3 之 2: 選取的元件] 頁面上,選取解決方案旁的核取方塊] 和 [下一步On the Restore from Backup — Step 2 of 3: Select Component to Restore page, select the check box that is next to the solution, and then click Next.

  6. 在從備份還原-步驟 3 之 3: 選取還原選項] 頁面的 [還原元件] 區段中,請確定 [解決方案] 出現在 [還原下列元件] 清單中。On the Restore from Backup — Step 3 of 3: Select Restore Options page, in the Restore Component section, make sure that Solution appears in the Restore the following component list.

    在 [僅還原組態設定] 區段中,確定已選取 [還原內容與組態設定] 選項。In the Restore Only Configuration Settings section, make sure that the Restore content and configuration settings option is selected.

    在 [還原選項] 區段的 [還原的類型] 下,選取 [相同的設定] 選項。對話方塊會隨即出現,請您確認該作業。按一下 [確定]。In the Restore Options section, under Type of Restore, select the Same configuration option. A dialog box appears that asks you to confirm the operation. Click OK.

    按一下 [開始還原]。Click Start Restore.

  7. 您可以在 [備份與還原工作狀態] 頁面上方的 [整備] 區段中,檢視所有復原工作的一般狀態。在同頁面底部的 [還原] 區段中,則可檢視目前復原工作的狀態。狀態頁面每 30 秒會自動更新。只要按一下 [重新整理],即可手動更新狀態詳細資料。備份與復原都是計時器服務工作。因此,數秒之後才會開始復原。You can view the general status of all recovery jobs at the top of the Backup and Restore Job Status page in the Readiness section. You can view the status for the current recovery job in the lower part of the page in the Restore section. The status page updates every 30 seconds automatically. You can manually update the status details by clicking Refresh. Backup and recovery are Timer service jobs. Therefore, it may take several seconds for the recovery to start.

    如有收到錯誤,可以檢閱 [備份與還原工作狀態] 頁面的 [失敗訊息] 欄。您也可以在步驟 3 中所指定之 UNC 路徑下的 Sprestore.log 檔案中查看詳細資訊。If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page. You can also find more details in the Sprestore.log file at the UNC path that you specified in step 3.

使用 PowerShell 還原信任的方案To restore a trusted solution 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:

    Restore-SPFarm -Directory <BackupFolder> -RestoreMethod Overwrite -BackupId <GUID> -Item <SolutionPath>
    

    其中:Where:

    • <備份資料夾> 為您要還原之目錄的 UNC 位置。<BackupFolder> is the UNC location of the directory that you want to restore from.

    • <GUID> 為您要還原之備份識別碼的 GUID。若未指定備份,則會使用最近的備份。<GUID> is the GUID of the backup ID that you want to restore from. If you do not specify a backup, the most recent one is used.

    • <方案路徑> 為備份樹狀結構中的解決方案路徑 (一般為:伺服器陣列\解決方案\ 方案名稱).<SolutionPath> is the path of the solution within the backup tree (usually farm\solutions\ SolutionName).

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

注意

[!附註] 建議您在執行命令列管理工作時使用 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.

還原沙箱方案Restoring a sandboxed solution

您不可僅還原部署為沙箱方案的自訂內容,而是必須還原伺服器陣列、Web 應用程式、內容資料庫或與自訂相關聯的網站集合。You cannot restore only customizations that were deployed as sandboxed solutions. Instead, you must restore the farm, Web application, content database, or site collection with which the customization is associated.

還原 SharePoint Server 中已製作的網站元素Restoring authored site elements in SharePoint Server

您無法僅還原製作的網站元素,而是必須還原伺服器陣列、Web 應用程式或與製作的網站元素相關聯之內容資料庫。You cannot restore only authored site elements. Instead, you must restore the farm, Web application, or content database with which the authored site element is associated.

還原 SharePoint Server 中的工作流程Restoring workflows in SharePoint Server

工作流程為您可還原之自訂的特殊案例。請確定備份與復原計劃中已包含下列任一適用於環境中的案例:Workflows are a special case of customizations that you can restore. Make sure that the backup and recovery plan includes any of the following scenarios that apply to the environment:

  • 宣告式工作流程 (例如在 SharePoint Designer 中建立的宣告式工作流程) 儲存在部署所在之網站集合的內容資料庫中。還原內容資料庫或網站集合時,會還原這些工作流程。Declarative workflows, such as those that are created in SharePoint Designer, are stored in the content database for the site collection to which they are deployed. Restoring the content database or site collection restores these workflows.

  • 自訂宣告式工作流程動作在下列三個位置包含元件:Custom declarative workflow actions have components in the following three locations:

    • 動作的 Visual Studio 2013 組件會儲存在全域組件快取 (GAC) 中。The Visual Studio 2013 assemblies for the actions are stored in the global assembly cache (GAC).

    • XML 定義檔 (.actions 檔) 儲存在 16\TEMPLATE< LCID>\Workflow 目錄中。The XML definition files (.actions files) are stored in the 16\TEMPLATE< LCID>\Workflow directory.

    • 將動作標示為授權類型的 XML 項目儲存在使用項目之 Web 應用程式的 Web.config 檔案中。An XML entry to mark the action as an authorized type is stored in the Web.config file for the Web applications in which it is used.

      若伺服器陣列工作流程使用自訂動作,則應使用檔案還原系統來還原這些檔案以及 XML 項目。檔案復原後,您可視需要重新套用這些檔案。If the farm workflows use custom actions, you should use a file restore system to restore these files and XML entries. You can reapply the files as needed after recovery.

  • 相依於自訂程式碼的工作流程,例如使用Visual Studio 2013 所建立的工作流程,會儲存於兩個位置。工作流程的Visual Studio 2013 組件儲存於 GAC 中,而 XML 定義檔則儲存於「功能」目錄中。這與 SharePoint Server 功能的其他類型相同,例如:網頁組件以及事件接收器。若工作流程已安裝為方案套件的一部分,則請遵循還原方案套件的指示進行。Workflows that depend on custom code, such as those that are created by using Visual Studio 2013, are stored in two locations. The Visual Studio 2013 assemblies for the workflow are stored in the GAC, and the XML definition files are stored in the Features directory. This is the same as other types of SharePoint Server features such as Web Parts and event receivers. If the workflow was installed as part of a solution package, follow the instructions for restoring solution packages.

  • 若您建立的自訂工作流程會與不是為部署工作流程所在的網站集合互動,則您必須還原這兩個網站集合才可復原工作流程。還原伺服器陣列已足以復原伺服器陣列中的所有網站集合,以及所有與網站集合相關聯的工作流程。If you create a custom workflow that interacts with a site collection other than the one where the workflow is deployed, you must restore both site collections to recover the workflow. Restoring a farm is sufficient to recover all site collections in the farm and all workflows that are associated with them.

  • 未部署的工作流程必須使用檔案系統備份應用系統,進行個別還原。Workflows that are not deployed must be restored separately by using a file system backup application.

還原 SharePoint Server 中對 Web.config 檔案的變更Restoring changes to the Web.config file in SharePoint Server

您可以執行伺服器陣列或僅設定還原,復原使用管理中心或 SharePoint Server API 以及物件模型所進行的 Web.config 檔案變更。You can recover changes to the Web.config file made by using Central Administration or the SharePoint Server APIs and object model by performing a farm or configuration-only restore.

您應使用檔案系統備份,保護不是由管理中心或 SharePoint API 及物件模型所進行的 Web.config 檔案變更。您可以使用檔案系統還原以復原備份。You should use a file system backup to protect changes to the Web.config file that are not made by using Central Administration or the SharePoint APIs and object model. You can recover the backup by using a file system restore.

還原 SharePoint Server 中尚未封裝為方案的已開發自訂Restoring developed customizations that are not packaged as solutions in SharePoint Server

還原尚未封裝為解決方案的已開發自訂,可能會是很複雜的程序,這是因為自訂檔案位置尚未標準化。Restoring developed customizations that are not packaged as solutions can be a complex process because the customization file locations are not standardized.

請與開發小組或自訂廠商連絡,以決定自訂若是在其他位置時,是否涉及額外的增益集軟體或檔案。建議您使用檔案系統還原解決方案還原目錄。下表列出網頁伺服器上儲存自訂的常見位置。Consult with the development team or customization vendor to determine whether the customizations involve additional add-in software or files in other locations. We recommend that you restore directories with a file system restore solution. The following table lists locations where customizations are typically stored on Web servers.

位置Location 描述Description
%PROGRAMFILES%\Common files\Microsoft Shared\Web Server Extensions\16%PROGRAMFILES%\Common files\Microsoft Shared\Web Server Extensions\16
經常更新的檔案、自訂組件、自訂範本、自訂網站定義Commonly updated files, custom assemblies, custom templates, custom site definitions
InetpubInetpub
IIS 虛擬目錄的位置Location of IIS virtual directories
%WINDIR%\Assembly%WINDIR%\Assembly
全域組件快取 (GAC):受保護的作業系統位置,該位置已安裝可提供完整系統存取的 Microsoft .NET Framework 程式碼組件Global assembly cache (GAC): a protected operating system location where the Microsoft .NET Framework code assemblies are installed to provide full system access

另請參閱See also

概念Concepts

備份 SharePoint Server 中的自訂Back up customizations in SharePoint Server

在 SharePoint Server 中還原伺服器陣列Restore farms in SharePoint Server

在 SharePoint Server 中還原伺服器陣列設定Restore farm configurations in SharePoint Server

在 SharePoint Server 中還原 Web 應用程式Restore web applications in SharePoint Server

在 SharePoint Server 中還原內容資料庫Restore content databases in SharePoint Server

在 SharePoint Server 中還原網站集合Restore site collections in SharePoint Server