将 Azure 存储用于 SQL Server 备份和还原Use Azure Storage for SQL Server backup and restore

适用于:是Azure VM 上的 SQL ServerAPPLIES TO: yesSQL Server on Azure VM

从 SQL Server 2012 SP1 CU2 开始,现可将 SQL Server 备份直接写入 Azure Blob 存储中。Starting with SQL Server 2012 SP1 CU2, you can now write SQL Server backups directly to Azure Blob storage. 可以使用此功能从 Azure Blob 存储和 SQL Server 数据库备份和还原。You can use this functionality to back up to and restore from Azure Blob storage and a SQL Server database. 备份到云具有以下优点,即,实现可用性、无地域复制场外存储限制,以及可以轻松将数据迁移到云和从云中迁移数据。Backup to the cloud offers benefits of availability, limitless geo-replicated off-site storage, and ease of migration of data to and from the cloud. 可以使用 Transact-SQL 或 SMO 来发布 BACKUP 或 RESTORE 语句。You can issue BACKUP or RESTORE statements by using Transact-SQL or SMO.


SQL Server 2016 引入了新功能;可以使用文件快照备份来执行几乎实时的备份和极其快速的还原。SQL Server 2016 introduces new capabilities; you can use file-snapshot backup to perform nearly instantaneous backups and incredibly quick restores.

本主题说明可以选择使用 Azure 存储执行 SQL Server 备份的原因,并介绍了相关的组件。This topic explains why you might choose to use Azure Storage for SQL Server backups and then describes the components involved. 可以使用本文结尾处提供的资源来访问演练和其他信息,以开始将此服务与 SQL Server 备份共同使用。You can use the resources provided at the end of the article to access walk-throughs and additional information to start using this service with your SQL Server backups.

使用 Azure Blob 存储执行 SQL Server 备份的优点Benefits of using Azure Blob storage for SQL Server backups

备份 SQL Server 时,会面临多项挑战。There are several challenges that you face when backing up SQL Server. 这些挑战包括存储管理、存储故障产生的风险、访问场外存储以及硬件配置。These challenges include storage management, risk of storage failure, access to off-site storage, and hardware configuration. 这些挑战当中许多都是通过使用 Azure Blob 存储进行 SQL Server 备份来解决的。Many of these challenges are addressed by using Azure Blob storage for SQL Server backups. 请考虑以下好处:Consider the following benefits:

  • 易用性:在 Azure Blob 中存储备份非常方便、灵活且可轻松访问场外存储。Ease of use: Storing your backups in Azure blobs can be a convenient, flexible, and easy to access off-site option. 为 SQL Server 备份创建场外存储就像修改现有脚本/作业以使用 BACKUP TO URL 语法一样简单。Creating off-site storage for your SQL Server backups can be as easy as modifying your existing scripts/jobs to use the BACKUP TO URL syntax. 场外存储通常应当远离生产数据库位置,以防止某个灾难可能同时影响场外和生产数据库位置。Off-site storage should typically be far enough from the production database location to prevent a single disaster that might impact both the off-site and production database locations. 通过选择异地复制 Azure blob,可以在发生可能影响整个区域的灾难时进一步加强保护。By choosing to geo-replicate your Azure blobs, you have an extra layer of protection in the event of a disaster that could affect the whole region.
  • 备份存档:对备份进行存档时,Azure Blob 存储提供可替代常用磁带存储方式的更好方式。Backup archive: Azure Blob storage offers a better alternative to the often used tape option to archive backups. 选择磁带存储时可能需要将数据实际运输到场外设施,并且需要采取一些介质保护措施。Tape storage might require physical transportation to an off-site facility and measures to protect the media. 在 Azure Blob 存储中存储备份可提供即时、具有高可用性且持久的存档方式。Storing your backups in Azure Blob storage provides an instant, highly available, and a durable archiving option.
  • 受管理的硬件:使用 Azure 服务没有硬件管理开销。Managed hardware: There is no overhead of hardware management with Azure services. Azure 服务可管理硬件并提供地域异地复制和硬件故障防护。Azure services manage the hardware and provide geo-replication for redundancy and protection against hardware failures.
  • 无限制的存储:通过启用直接备份到 Azure Blob,可以访问几乎无限的存储。Unlimited storage: By enabling a direct backup to Azure blobs, you have access to virtually unlimited storage. 或者,还可以选择备份到 Azure 虚拟机磁盘,所受的限制取决于计算机的大小。Alternatively, backing up to an Azure virtual machine disk has limits based on machine size. 只能将有限数量的磁盘附加到用于备份的 Azure 虚拟机。There is a limit to the number of disks you can attach to an Azure virtual machine for backups. 对特大实例的限制为 16 个磁盘;对较小实例的磁盘限制数更少。This limit is 16 disks for an extra large instance and fewer for smaller instances.
  • 备份可用性:存储在 Azure Blob 中的备份可随时从任何位置使用,并可供轻松访问以还原到 SQL Server 实例,而无需进行数据库附加/分离,或者无需下载和附加 VHD。Backup availability: Backups stored in Azure blobs are available from anywhere and at any time and can easily be accessed for restores to a SQL Server instance, without the need for database attach/detach or downloading and attaching the VHD.
  • 成本:只需要为使用的服务付费。Cost: Pay only for the service that is used. 作为场外和备份存档方式可能更加划算。Can be cost-effective as an off-site and backup archive option. 有关详细信息,请参阅 Azure 定价计算器Azure 定价文章See the Azure pricing calculator, and the Azure Pricing article for more information.
  • 存储快照:如果数据库文件存储在 Azure Blob 中并且使用的是 SQL Server 2016,则可以使用文件快照备份来执行几乎实时的备份和极其快速的还原。Storage snapshots: When database files are stored in an Azure blob and you are using SQL Server 2016, you can use file-snapshot backup to perform nearly instantaneous backups and incredibly quick restores.

有关更多详细信息,请参阅使用 Azure Blob 存储执行 SQL Server 备份和还原For more details, see SQL Server Backup and Restore with Azure Blob storage.

接下来两节介绍 Azure Blob 存储,包括必要的 SQL Server 组件。The following two sections introduce Azure Blob storage, including the required SQL Server components. 若要从 Azure Blob 存储成功进行备份和还原,一定要了解这些组件及其交互方式。It is important to understand the components and their interaction to successfully use backup and restore from Azure Blob storage.

Azure Blob 存储组件Azure Blob storage components

备份到 Azure Blob 存储时,会使用以下 Azure 组件。The following Azure components are used when backing up to Azure Blob storage.

组件Component 说明Description
存储帐户Storage account 存储帐户是所有存储服务的起点。The storage account is the starting point for all storage services. 若要访问 Azure Blob 存储,请先创建一个 Azure 存储帐户。To access Azure Blob storage, first create an Azure Storage account. 有关 Azure Blob 存储的详细信息,请参阅如何使用 Azure Blob 存储For more information about Azure Blob storage, see How to use Azure Blob storage.
容器Container 容器提供一组 Blob 集,并且可存储无限数量的 Blob。A container provides a grouping of a set of blobs, and can store an unlimited number of Blobs. 若要将 SQL Server 备份写入到 Azure Blob 存储,必须创建至少一个根容器。To write a SQL Server backup to Azure Blob storage, you must have at least the root container created.
BlobBlob 任何类型和大小的文件。A file of any type and size. 可使用以下 URL 格式对 Blob 进行寻址:https://[storage account].blob.core.chinacloudapi.cn/[container]/[blob]Blobs are addressable using the following URL format: https://[storage account].blob.core.chinacloudapi.cn/[container]/[blob]. 有关页 Blob 的详细信息,请参阅了解块 Blob 和页 BlobFor more information about page Blobs, see Understanding Block and Page Blobs

SQL Server 组件SQL Server components

备份到 Azure Blob 存储时,会使用以下 SQL Server 组件。The following SQL Server components are used when backing up to Azure Blob storage.

组件Component 说明Description
URLURL URL 指定到唯一备份文件的统一资源标识符 (URI)。A URL specifies a Uniform Resource Identifier (URI) to a unique backup file. URL 用于提供 SQL Server 备份文件的位置和名称。The URL is used to provide the location and name of the SQL Server backup file. URL 必须指向实际 blob,而不是仅指向容器。The URL must point to an actual blob, not just a container. 如果 blob 不存在,则创建一个。If the blob does not exist, it is created. 如果指定了现有 blob,除非指定了 > WITH FORMAT 选项,否则 BACKUP 将失败。If an existing blob is specified, BACKUP fails, unless the > WITH FORMAT option is specified. 以下是在 BACKUP 命令中指定的 URL 示例:http[s]://[存储帐户].blob.core.chinacloudapi.cn/[容器]/[文件名.bak]The following is an example of the URL you would specify in the BACKUP command: http[s]://[storageaccount].blob.core.chinacloudapi.cn/[container]/[FILENAME.bak]. HTTPS 不是必需的,但建议使用它。HTTPS is recommended but not required.
凭据Credential 连接到 Azure Blob 存储并通过其进行身份验证所需的信息将存储为凭据。The information that is required to connect and authenticate to Azure Blob storage is stored as a credential. 为了使 SQL Server 将备份写入 Azure Blob 或从中进行还原,必须创建 SQL Server 凭据。In order for SQL Server to write backups to an Azure Blob or restore from it, a SQL Server credential must be created. 有关详细信息,请参阅 SQL Server 凭据For more information, see SQL Server Credential.


SQL Server 2016 已更新以支持块 blob。SQL Server 2016 has been updated to support block blobs. 有关详细信息,请参阅教程:将 Azure Blob 存储用于 SQL Server 2016 数据库Please see Tutorial: Using Azure Blob storage with SQL Server 2016 databases for more details.

后续步骤Next steps

  1. 创建 Azure 帐户(如果还没有帐户)。Create an Azure account if you don't already have one. 如果你正在评估 Azure,请考虑使用试用版If you are evaluating Azure, consider the trial.

  2. 接着,完成以下教程之一,这些教程会引导创建存储帐户以及执行还原。Then go through one of the following tutorials that walk you through creating a storage account and performing a restore.

  3. 查看其他文档,从使用 Azure Blob 存储进行 SQL Server 备份和还原开始。Review additional documentation starting with SQL Server Backup and Restore with Azure Blob storage.

如果有任何问题,请查看 SQL Server 备份到 URL 最佳实践和故障排除主题。If you have any problems, review the topic SQL Server Backup to URL Best Practices and Troubleshooting.

有关其他 SQL Server 备份和还原选项,请参阅 Azure 虚拟机上的 SQL Server 的备份和还原For other SQL Server backup and restore options, see Backup and Restore for SQL Server on Azure Virtual Machines.