長期保留-Azure SQL Database 和 Azure SQL 受控執行個體Long-term retention - Azure SQL Database and Azure SQL Managed Instance

許多應用程式具有法規、合規性或其他商務用途,需要您保留超過7-35 天的資料庫備份,Azure SQL Database 和 Azure SQL 受控執行個體 自動備份所提供的備份。Many applications have regulatory, compliance, or other business purposes that require you to retain database backups beyond the 7-35 days provided by Azure SQL Database and Azure SQL Managed Instance automatic backups. 藉由使用長期保留 (LTR) 功能,您可以在 Azure Blob 儲存體中儲存指定的 SQL Database 和 SQL 受控執行個體完整備份,並設定最多10年的 冗余By using the long-term retention (LTR) feature, you can store specified SQL Database and SQL Managed Instance full backups in Azure Blob storage with configured redundancy for up to 10 years. 之後您可以將任何備份還原為新的資料庫。You can then restore any backup as a new database.

您可以針對 Azure SQL Database 啟用長期保留,且在 Azure SQL 受控執行個體的有限公開預覽中。Long time retention can be enabled for Azure SQL Database, and is in limited public preview for Azure SQL Managed Instance. 本文提供長期保留的概念性總覽。This article provides a conceptual overview of long-term retention. 若要設定長期保留,請參閱 設定 AZURE SQL DATABASE ltr設定 AZURE SQL 受控執行個體 ltrTo configure long-term retention, see Configure Azure SQL Database LTR and Configure Azure SQL Managed Instance LTR.

注意

您可以使用 SQL Agent 作業來排程僅限複製的資料庫備份,以替代超過 35 天的 LTR。You can use SQL Agent jobs to schedule copy-only database backups as an alternative to LTR beyond 35 days.

長期保留的運作方式How long-term retention works

長期備份保留 (LTR) 會運用自動建立的完整資料庫備份來啟用時間點還原 (PITR)。Long-term backup retention (LTR) leverages the full database backups that are automatically created to enable point-time restore (PITR). 如果已設定 LTR 原則,則會將這些備份複製到不同的 blob 以供長期儲存。If an LTR policy is configured, these backups are copied to different blobs for long-term storage. 複製是背景工作,對資料庫工作負載沒有任何效能影響。The copy is a background job that has no performance impact on the database workload. SQL Database 中每個資料庫的 LTR 原則也可以指定 LTR 備份的建立頻率。The LTR policy for each database in SQL Database can also specify how frequently the LTR backups are created.

若要啟用 LTR,您可以使用四個參數的組合來定義原則:每週備份保留 (W) 、每月備份保留 (M) 、每年備份保留 (Y) 和年中的周 (WeekOfYear) 。To enable LTR, you can define a policy using a combination of four parameters: weekly backup retention (W), monthly backup retention (M), yearly backup retention (Y), and week of year (WeekOfYear). 如果指定 W,每週一次的備份會複製到長期儲存體。If you specify W, one backup every week will be copied to the long-term storage. 如果您指定 M,每個月的第一次備份將會複製到長期儲存體。If you specify M, the first backup of each month will be copied to the long-term storage. 如果指定 Y,在以 WeekOfYear 指定的當週進行的一次備份會複製到長期儲存體。If you specify Y, one backup during the week specified by WeekOfYear will be copied to the long-term storage. 如果在設定原則時,指定的 WeekOfYear 是過去的,則會在下一年建立第一個 LTR 備份。If the specified WeekOfYear is in the past when the policy is configured, the first LTR backup will be created in the following year. 每個備份都會根據建立 LTR 備份時所設定的原則參數,保留在長期儲存體中。Each backup will be kept in the long-term storage according to the policy parameters that are configured when the LTR backup is created.

注意

LTR 原則的任何變更只適用于未來的備份。Any change to the LTR policy applies only to future backups. 例如,如果每週備份保留 (W) 、每月備份保留 (M) ,或每年備份保留 (Y) 修改,則新的保留設定只會套用至新的備份。For example, if weekly backup retention (W), monthly backup retention (M), or yearly backup retention (Y) is modified, the new retention setting will only apply to new backups. 將不會修改現有備份的保留。The retention of existing backups will not be modified. 如果您想要在保留期限到期之前刪除舊的 LTR 備份,您將需要 手動刪除備份If your intention is to delete old LTR backups before their retention period expires, you will need to manually delete the backups.

LTR 原則的範例:Examples of the LTR policy:

  • W=0, M=0, Y=5, WeekOfYear=3W=0, M=0, Y=5, WeekOfYear=3

    每年的第三次完整備份將會保留五年。The third full backup of each year will be kept for five years.

  • W=0, M=3, Y=0W=0, M=3, Y=0

    每個月的第一個完整備份將會保留三個月。The first full backup of each month will be kept for three months.

  • W=12, M=0, Y=0W=12, M=0, Y=0

    每個每週完整備份皆會保留 12 週。Each weekly full backup will be kept for 12 weeks.

  • W=6, M=12, Y=10, WeekOfYear=16W=6, M=12, Y=10, WeekOfYear=16

    每週完整備份會保留六周。Each weekly full backup will be kept for six weeks. 但每月的第 1 個完整備份除外,這個備份會保留 12 個月。Except first full backup of each month, which will be kept for 12 months. 以及每年的第 16 週的完整備份除外,這個備份會保留 10 年。Except the full backup taken on 16th week of year, which will be kept for 10 years.

下表說明以下原則的長期備份日程和到期日:The following table illustrates the cadence and expiration of the long-term backups for the following policy:

W=12 週 (84 天)、M=12 個月 (365 天)、Y=10 年 (3650 天)、WeekOfYear=15 (4 月 15 日後那一周)W=12 weeks (84 days), M=12 months (365 days), Y=10 years (3650 days), WeekOfYear=15 (week after April 15)

ITR 範例

如果您修改上述原則,並設定 W = 0 (沒有每週備份) ,備份複本的步調將會變更,如上表所示的反白顯示日期。If you modify the above policy and set W=0 (no weekly backups), the cadence of backup copies will change as shown in the above table by the highlighted dates. 用來保留這些備份所需的儲存體數量會跟著減少。The storage amount needed to keep these backups would reduce accordingly.

重要

個別 LTR 備份的時間是由 Azure 所控制。The timing of individual LTR backups is controlled by Azure. 您無法手動建立 LTR 備份,或控制備份建立的時間。You cannot manually create an LTR backup or control the timing of the backup creation. 設定 LTR 原則之後,最多可能需要7天的時間,第一個 LTR 備份才會顯示在可用備份清單中。After configuring an LTR policy, it may take up to 7 days before the first LTR backup will show up on the list of available backups.

異地複寫和長期備份保留Geo-replication and long-term backup retention

如果您使用主動式異地複寫或容錯移轉群組做為您的商務持續性解決方案,您應該為最終容錯移轉做好準備,並在次要資料庫或實例上設定相同的 LTR 原則。If you're using active geo-replication or failover groups as your business continuity solution, you should prepare for eventual failovers and configure the same LTR policy on the secondary database or instance. 您的 LTR 儲存體成本不會增加,因為不會從次要複本產生備份。Your LTR storage cost won't increase as backups aren't generated from the secondaries. 只有當次要複本變成主要複本時,才會建立備份。The backups are only created when the secondary becomes primary the backups will be created. 它可確保在觸發容錯移轉且主要區域移至次要區域時,不會中斷的 LTR 備份產生。It ensures non-interrupted generation of the LTR backups when the failover is triggered and the primary moves to the secondary region.

注意

當原始的主資料庫從造成容錯移轉的中斷中復原時,它會變成新的次要資料庫。When the original primary database recovers from an outage that caused the failover, it will become a new secondary. 因此,備份的建立不會繼續,而且現有的 LTR 原則將不會生效,除非它再次變成主要資料庫。Therefore, the backup creation will not resume and the existing LTR policy will not take effect until it becomes the primary again.

SQL 受控執行個體支援SQL Managed Instance support

搭配 Azure SQL 受控執行個體使用長期備份保留有下列限制:Using long-term backup retention with Azure SQL Managed Instance has the following limitations:

  • 有限的公開預覽 -此預覽版僅適用于 EA 和 CSP 訂用帳戶,且受限於有限的可用性。Limited public preview - This preview is only available to EA and CSP subscriptions and is subject to limited availability.
  • 僅限 PowerShell -目前沒有 Azure 入口網站支援。PowerShell only - There's currently no Azure portal support. 必須使用 PowerShell 來啟用 LTR。LTR must be enabled using PowerShell.

若要要求註冊,請建立 Azure 支援票證To request enrollment, create an Azure support ticket. 針對 [問題類型] 選取 [技術問題],針對 [服務選擇 SQL 受控執行個體],針對問題類型選取 [ 備份]、[還原] 和 [商務持續性/長期備份保留]。For issue type select technical issue, for service choose SQL Managed Instance, and for the problem type select Backup, Restore, and Business continuity / Long-term backup retention. 在您的要求中,請確定您想要註冊至 SQL 受控執行個體的限時公開預覽。In your request, please state you would like to be enrolled into limited public preview of LTR for SQL Managed Instance.

設定長期備份保留期Configure long-term backup retention

您可以使用適用于 Azure SQL Database 的 Azure 入口網站和 PowerShell,以及適用于 Azure SQL 受控執行個體的 PowerShell 來設定長期備份保留。You can configure long-term backup retention using the Azure portal and PowerShell for Azure SQL Database, and PowerShell for Azure SQL Managed Instance. 若要從 LTR 儲存體還原資料庫,可以依時間戳記選取特定備份。To restore a database from the LTR storage, you can select a specific backup based on its timestamp. 您可以將資料庫還原到與原始資料庫位於相同訂用帳戶下的任何現有伺服器或受控實例。The database can be restored to any existing server or managed instance under the same subscription as the original database.

若要瞭解如何設定長期保留或從備份還原資料庫,以使用 Azure 入口網站或 PowerShell 進行 SQL Database,請參閱 管理 Azure SQL Database 長期備份保留To learn how to configure long-term retention or restore a database from backup for SQL Database using the Azure portal or PowerShell, see Manage Azure SQL Database long-term backup retention

若要瞭解如何使用 PowerShell 設定 SQL 受控執行個體的長期保留或從備份還原資料庫,請參閱 管理 AZURE sql 受控執行個體長期備份保留To learn how to configure long-term retention or restore a database from backup for SQL Managed Instance using PowerShell, see Manage Azure SQL Managed Instance long-term backup retention.

若要從 LTR 儲存體還原資料庫,可以依時間戳記選取特定備份。To restore a database from the LTR storage, you can select a specific backup based on its timestamp. 可將資料庫還原至原始資料庫相同訂用帳戶底下的任何現有伺服器。The database can be restored to any existing server under the same subscription as the original database. 若要瞭解如何使用 Azure 入口網站或 PowerShell 從 LTR 備份還原資料庫,請參閱 管理 Azure SQL Database 長期備份保留To learn how to restore your database from an LTR backup, using the Azure portal, or PowerShell, see Manage Azure SQL Database long-term backup retention. 在您的要求中,請確定您想要在 SQL 受控執行個體的限時公開預覽版中註冊。In your request, please state you would like to be enrolled in the limited public preview of LTR for SQL Managed Instance.

後續步驟Next steps

因為資料庫備份可保護資料免於意外損毀或刪除,是商務持續性和災害復原策略中不可或缺的一環。Because database backups protect data from accidental corruption or deletion, they're an essential part of any business continuity and disaster recovery strategy. 若要深入了解其他 SQL Database 商務持續性解決方案,請參閱商務持續性概觀To learn about the other SQL Database business-continuity solutions, see Business continuity overview.