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

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

您可以使用 SharePoint 管理中心網站 或 Microsoft PowerShell 來備份對 SharePoint Server 網站所做的自訂。所使用的備份工具取決於已部署的環境類型、備份排程的需要以及您組織的服務等級協定而定。You can back up customizations that are made to SharePoint Server sites by using the SharePoint Central Administration website or Microsoft PowerShell. Which backup tool you use depends on what kind of environment you have deployed, what your backup schedule requires, and what service level agreements you have made with your organization.

開始之前Before you begin

開始這項作業之前,請先檢閱下列清單,了解可以對網站進行的自訂項目:Before you begin this operation, review the following list of possible customizations that you can make to your sites:

  • 封裝為方案 (.wsp 檔案) 的自訂。方案包含「開發的網站元素」,而且一般是由開發人員所建立。開發的網站元素包括下列各項:Customizations packaged as solutions (.wsp files). Solutions contain developed site elements, and are typically created by developers. Developed site elements include the following:

    • 網頁組件Web Parts

    • 工作流程Workflows

    • 網站和清單定義Site and list definitions

    • 文件轉換程式Document converters

    • 事件接收器Event receivers

    • 計時器工作Timer jobs

    • 組件Assemblies

  • 「已製作網站元素」通常是由網頁設計者所建立,而且不是明確編譯並放在內容資料庫中。已製作網站元素包括下列項目:Authored site elements, which are typically created by web designers, are not explicitly compiled and are located in a content database. Authored site elements include the following:

    • 主版頁面Master pages

    • 階層式樣式表Cascading style sheets

    • 表單Forms

    • 版面配置頁面Layout pages

  • 變更 Web.config 檔案Changes to the Web.config file

  • 協力廠商解決方案及其相關的二進位檔案與登錄機碼 (如 IFilter)Third-party solutions and their associated binary files and registry keys, such as IFilters

  • 透過瀏覽器進行直接編輯所建立的網站變更Changes to sites created by direct editing through the browser

  • 未封裝為方案的已開發自訂Developed customizations that are not packaged as solutions

注意

[!附註] 其中所有種類的自訂都需要不同類型的備份。Each of these kinds of customizations requires a different type of backup.

備份 SharePoint Server 中的方案套件Back up solution packages in SharePoint Server

使用 SharePoint Designer 或 Visual Studio 建立解決方案套件。我們強烈建議將所有自訂項目部署為解決方案套件。如需詳細資訊,請參閱<建立 SharePoint 解決方案套件>。Solution packages can be created by using SharePoint Designer or Visual Studio. We strongly recommend that all customizations be deployed as solution packages. For more information, see Creating SharePoint Solution Packages.

方案套件是可部署且可重複使用的檔案,可以包含一組套用至網站的功能、網站定義和組件,而且可以個別予以啟用和停用。方案套件可以包括網頁組件、網站或清單定義、自訂欄、新內容類型、自訂欄位、自訂動作、編碼工作流程或工作流程活動與條件。A solution package is a deployable, reusable file that can contain a set of features, site definitions, and assemblies that apply to sites, and that you can enable or disable individually. Solution packages can include Web Parts, site or list definitions, custom columns, new content types, custom fields, custom actions, coded workflows, or workflow activities and conditions.

用來備份方案套件的方法取決於自訂是否部署為信任的方案或沙箱化解決方案 (部分信任的程式碼)。The method that you use to back up solution packages is determined by whether the customizations are deployed as trusted solutions or sandboxed solutions (partially trusted code).

信任的方案是伺服器陣列管理員所部署的方案套件。信任的方案會部署至整個伺服器陣列,而且可以用於伺服器陣列內的任何網站。信任的方案是儲存在設定資料庫中。使用 SharePoint Server 備份來備份伺服器陣列時,會備份信任的方案,並將其併入僅設定備份中。您也可以將信任的方案備份為群組,或個別備份。您可以在備份階層中看到信任的方案。Trusted solutions are solution packages that farm administrators deploy. Trusted solutions are deployed to the entire 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. You can also back up trusted solutions as a group or individually. Trusted solutions are visible in the backup hierarchy.

沙箱化解決方案是網站集合管理員可以部署至單一網站集合的方案套件。沙箱化解決方案會儲存在關聯至方案套件部署所在之網站集合的內容資料庫中。其雖包含在 SharePoint Server 伺服器陣列、Web 應用程式、內容資料庫和網站集合備份中,但不會顯示在備份階層中,且無法個別進行選取或備份。Sandboxed solutions are solution packages that site collection administrators can deploy to a single site collection. Sandboxed solutions are stored in the content database that is associated with the site collection to which the solution packages are deployed. They are included in SharePoint Server farm, web application, content database, and site collection backups, but are not visible in the backup hierarchy and cannot be selected or backed up individually.

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

使用管理中心備份信任的方案To back up trusted solutions by using Central Administration

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

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

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

  4. 在 [執行備份 - 步驟 2 之 1: 選取要備份的元件] 頁面上,選取 [解決方案],然後按 [下一步]。On the Perform a Backup — Step 1 of 2: Select Component to Back Up page, select Solutions, and then click Next.

    如果您只想要備份單一方案,也可以選取個別方案。You can also select an individual solution, if you only want to back up a single solution.

  5. 在 [開始備份 - 步驟 2 之 2: 選取備份選項] 頁面的 [備份類型] 區段中,選取 [完整] 或 [差異]。On the Start Backup — Step 2 of 2: Select Backup Options page, in the Backup Type section, select either Full or Differential.

    注意

    若是第一次備份方案,必須使用 [完整] 選項。您必須先執行完整備份,才可執行差異備份。If you are backing up the solution for the first time, you must use the Full option. You must perform a full backup before you can perform a differential backup.

  6. 在 [備份檔案位置] 區段中,輸入備份資料夾的通用命名慣例 (UNC) 路徑,然後按一下 [開始備份]。In the Backup File Location section, type the Universal Naming Convention (UNC) path of the backup folder, and then click Start Backup.

  7. 您可以在 [備份與還原工作狀態] 頁面上方的 [整備] 區段中,檢視所有備份工作的一般狀態。在同頁面底部的 [備份] 區段中,則可檢視目前備份工作的狀態。狀態頁面每 30 秒會自動更新。只要按一下 [重新整理],即可手動更新狀態詳細資料。備份與復原都是計時器服務工作。因此,數秒之後才會開始備份。You can view the general status of all backup jobs at the top of the Backup and Restore Job Status page in the Readiness section. You can view the status of the current backup job in the lower part of the page in the Backup 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 backup to start.

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

    若要使用 PowerShell 備份信任的方案To back up trusted solutions by using PowerShell

  8. 確認您具備下列成員資格: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.

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

  10. 在 PowerShell 命令提示字元處輸入下列命令,以備份伺服器陣列中的所有解決方案。若要備份單一解決方案,請將解決方案名稱新增至項目路徑 "farm\solutions"。At the PowerShell command prompt, type the following command to back up all of the solutions in the farm. To back up a single solution, add the name of the solution to the item path "farm\solutions".

    Backup-SPFarm -backupmethod full -directory <UNC location> -item "farm\solutions"
    

    其中:Where:

    • <UNC location> 是您用來儲存備份檔案的目錄 UNC 位置。<UNC location> is the UNC location of the directory where you store the backup file.

如需詳細資訊,請參閱<Backup-SPFarm>。For more information, see Backup-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.

備份 SharePoint Server 中的沙箱化解決方案Backing up sandboxed solutions in SharePoint Server

您不能備份僅沙箱化解決方案。但是,您必須備份伺服器陣列、 Web 應用程式或內容資料庫與沙箱化解決方案相關聯。You cannot back up only sandboxed solutions. Instead, you must back up the farm, Web application, or content database with which the sandboxed solution is associated.

備份 SharePoint Server 中的已製作網站元素Back up authored site elements in SharePoint Server

您不能備份僅限已製作的網站元素。但是,您必須備份伺服器陣列、 Web 應用程式或內容與已製作的網站元素相關聯的資料庫。You cannot back up only authored site elements. Instead, you must back up the farm, Web application, or content database with which the authored site element is associated.

備份 SharePoint Server 中的工作流程Back up workflows in SharePoint Server

工作流程是您可以備份的特殊自訂案例。請務必確認您的備份及復原計劃能解決套用至環境中的任何下列案例:Workflows are a special case of customizations that you can back up. Make sure that your backup and recovery plan addresses any of the following scenarios that apply to your environment:

  • 宣告式工作流程 (例如在 SharePoint Designer 中建立的工作流程) 儲存在部署所在之網站集合的內容資料庫中。備份內容資料庫可保護這些工作流程。Declarative workflows, such as those that were created in SharePoint Designer, are stored in the content database for the site collection to which they are deployed. Backing up the content database protects 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 backup system to protect these files and XML entries. Similar to features such as Web Parts and event receivers, these files should be reapplied to the farm as needed after recovery.

  • 相依於自訂程式碼的工作流程,例如使用 Visual Studio 所建立的工作流程,會儲存在兩個位置。工作流程的 Visual Studio 組件會儲存在 GAC 中,而 XML 定義檔則儲存在「功能」目錄中。這與其他類型的 SharePoint 功能相同,例如:網頁組件以及事件接收器。若工作流程已安裝為方案套件的一部分,備份伺服器陣列、Web 應用程式、內容資料庫或網站集合即可保護這些工作流程。Workflows that depend on custom code, such as those that are created by using Visual Studio, are stored in two locations. The Visual Studio 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 features such as Web Parts and event receivers. If the workflow was installed as part of a solution package, backing up the farm, Web application, content database, or site collection protects these workflows.

  • 如果建立自訂工作流程,與非工作流程部署所在的網站集合互動,您必須同時備份這兩個網站集合,以保護工作流程。這包括寫入歷程記錄清單或其他網站集合的其他自訂清單之工作流程。執行伺服器陣列備份便足以備份伺服器陣列中的所有網站集合,以及相關聯的所有工作流程。If you create a custom workflow that interacts with a site collection other than the one where the workflow is deployed, you must back up both site collections to protect the workflow. This includes workflows that write to a history list or other custom list in another site collection. Performing a farm backup is sufficient to back up all site collections in the farm and all workflows that are associated with them.

  • 尚未部署的工作流程必須分開備份及還原。當您開發新工作流程但尚未部署至 SharePoint Server 伺服器陣列時,請確定使用檔案系統備份應用程式,備份工作流程專案檔案儲存所在的資料夾。Workflows that are not yet deployed must be backed up and restored separately. When you are developing a new workflow but have not yet deployed it to the SharePoint Server farm, make sure that you back up the folder where you store the workflow project files by a file system backup application.

備份 SharePoint Server 中 Web.config 檔案的變更Back up changes to the Web.config file in SharePoint Server

SharePoint Server 的常見自訂是變更 Web.config 檔案。強烈建議您使用管理中心或 SharePoint Server API 和物件模型,來變更 Web.config 檔案。因為這些變更是儲存至設定資料庫,所以可以從伺服器陣列或僅設定備份復原它們。A common customization to SharePoint Server is to change the Web.config file. We strongly recommend that you make changes to the Web.config file by using Central Administration or the SharePoint Server APIs and object model. Because these changes are stored in the configuration database, they can be recovered from a farm or configuration-only backup.

應該使用檔案系統備份保護不是使用管理中心或 SharePoint Server API 和物件模型所進行的 Web.config 檔案變更。Changes to the Web.config file that are not made by using Central Administration or the SharePoint Server APIs and object model should be protected by using a file system backup.

注意

[!附註] 如果您使用表單型驗證,則 Web.config 檔案中的提供者登錄是手動的,而且不是透過 SharePoint Server 備份進行保護。在此情況下,請一定要使用檔案系統備份來備份 Web.config 檔案。If you are using forms-based authentication, provider registration in the Web.config file is manual, and is not protected by SharePoint Server backup. In this case, make sure that you back up the Web.config file by using a file system backup.

備份 SharePoint Server 中的協力廠商產品Back up third-party products in SharePoint Server

如果協力廠商產品部署為方案套件,則它們是透過 SharePoint Server 備份所保護。建議您保留所有原始檔案、分配媒體、文件以及安裝所需的授權和產品金鑰。If third-party products are deployed as solution packages, they are protected by SharePoint Server backup. We recommend that you keep all the original files, distribution media, documentation, and the license and product keys that are required for installation.

備份 SharePoint Server 中尚未封裝為方案的已開發自訂Back up developed customizations that are not packaged as solutions in SharePoint Server

因為自訂檔案位置可能未儲存於標準化位置,而且 SharePoint Server 未自動備份自訂檔案,所以備份所自訂但未部署為方案套件的自訂,可能是十分複雜的程序。Backing up developed customizations that are not deployed as solution packages can be a complex process because the customization file locations might not be stored in standardized places and SharePoint Server does not automatically back them up.

請與開發小組或自訂廠商連絡,以決定自訂在其他位置是否涉及額外的增益集軟體或檔案。建議您備份含有檔案系統備份方案的這些目錄。下表列出所開發之自訂在網頁伺服器上的常見儲存位置。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 back up these directories with a file system backup solution. The following table lists locations where developed 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 中還原自訂Restore customizations in SharePoint Server

在 SharePoint Server 中備份伺服器陣列Back up farms in SharePoint Server

在 SharePoint Server 中備份伺服器陣列設定Back up farm configurations in SharePoint Server

在 SharePoint Server 中備份 Web 應用程式Back up web applications in SharePoint Server

在 SharePoint Server 中備份內容資料庫Back up content databases in SharePoint Server

在 SharePoint Server 中備份網站集合Back up site collections in SharePoint Server

Update Workflow in SharePoint Server 2013Update Workflow in SharePoint Server