在 Azure Database for MySQL 中进行备份和还原Backup and restore in Azure Database for MySQL

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

Azure Database for MySQL 可自动创建服务器备份并将其存储在用户配置的本地冗余或异地冗余存储中。Azure Database for MySQL automatically creates server backups and stores them in user configured locally redundant or geo-redundant storage. 备份可以用来将服务器还原到某个时间点。Backups can be used to restore your server to a point-in-time. 备份和还原是任何业务连续性策略的基本组成部分,因为它们可以保护数据免遭意外损坏或删除。Backup and restore are an essential part of any business continuity strategy because they protect your data from accidental corruption or deletion.

备份Backups

Azure Database for MySQL 对数据文件和事务日志进行备份。Azure Database for MySQL takes backups of the data files and the transaction log. 我们会进行完整备份或差异备份。We either take full and differential backups. 可以通过这些备份将服务器还原到所配置的备份保留期中的任意时间点。These backups allow you to restore a server to any point-in-time within your configured backup retention period. 默认的备份保留期为七天。The default backup retention period is seven days. 可以选择将其配置为长达 35 天。You can optionally configure it up to 35 days. 所有备份都使用 AES 256 位加密进行加密。All backups are encrypted using AES 256-bit encryption.

这些备份文件不公开给用户,因此无法导出。These backup files are not user-exposed and cannot be exported. 这些备份只能用于 Azure Database for MySQL 中的还原操作。These backups can only be used for restore operations in Azure Database for MySQL. 可以使用 mysqldump 复制数据库。You can use mysqldump to copy a database.

备份频率Backup frequency

通常情况下,完整备份每周进行一次,差异备份每天进行两次,事务日志备份每五分钟进行一次。Generally, full backups occur weekly, differential backups occur twice a day, and transaction log backups occur every five minutes. 创建服务器后,立即计划完整备份的第一个快照。The first snapshot of full backup is scheduled immediately after a server is created. 在大型还原服务器上,初始完整备份可能需要更长时间。The initial full backup can take longer on a large restored server. 新服务器可以还原到的最早时间点是完成初始完整备份的时间。The earliest point in time that a new server can be restored to is the time at which the initial full backup is complete.

备份保留Backup retention

根据服务器上的备份保持期设置来保留备份。Backups are retained based on the backup retention period setting on the server. 可以选择 7 到 35 天的保留期。You can select a retention period of 7 to 35 days. 默认保持期为 7 天。The default retention period is 7 days. 可以在服务器创建期间或以后通过使用 Azure 门户Azure CLI 更新备份配置来设置保留期。You can set the retention period during server creation or later by updating the backup configuration using Azure portal or Azure CLI.

备份保留期控制可以往回检索多长时间的时间点还原,因为它基于可用备份。The backup retention period governs how far back in time a point-in-time restore can be retrieved, since it's based on backups available. 从恢复的角度来看,备份保留期也可以视为恢复时段。The backup retention period can also be treated as a recovery window from a restore perspective. 在备份保留期间内执行时间点还原所需的所有备份都保留在备份存储中。All backups required to perform a point-in-time restore within the backup retention period are retained in backup storage. 例如,如果备份保留期设置为 7 天,则可认为恢复时段是最近 7 天。For example, if the backup retention period is set to 7 days, the recovery window is considered last 7 days. 在这种情况下,将保留在过去 7 天内还原服务器所需的所有备份。In this scenario, all the backups required to restore the server in last 7 days are retained. 备份保留期为 7 天:服务器将保留最多 2 个完整数据库备份、所有差异备份和自最早的完整数据库备份以来执行的事务日志备份。With a backup retention window of seven days: Servers will retain up to 2 full database backups, all the differential backups, and transaction log backups performed since the earliest full database backup.

备份冗余选项Backup redundancy options

使用 Azure Database for MySQL 时,可以灵活地在“常规用途”层和“内存优化”层中选择本地冗余或异地冗余备份存储。Azure Database for MySQL provides the flexibility to choose between locally redundant or geo-redundant backup storage in the General Purpose and Memory Optimized tiers. 当备份存储在异地冗余备份存储中时,这些备份不仅会存储在托管服务器所在的区域中,还会复制到配对的数据中心When the backups are stored in geo-redundant backup storage, they are not only stored within the region in which your server is hosted, but are also replicated to a paired data center. 这样可以在发生灾难时提供更好的保护,并且可以将服务器还原到其他区域。This provides better protection and ability to restore your server in a different region in the event of a disaster. “基本”层仅提供本地冗余备份存储。The Basic tier only offers locally redundant backup storage.

重要

只能在服务器创建期间为备份配置本地冗余或异地冗余存储。Configuring locally redundant or geo-redundant storage for backup is only allowed during server create. 预配服务器以后,不能更改备份存储冗余选项。Once the server is provisioned, you cannot change the backup storage redundancy option.

备份存储成本Backup storage cost

Azure Database for MySQL 最高可以提供 100% 的已预配服务器存储作为备份存储,不收取任何额外费用。Azure Database for MySQL provides up to 100% of your provisioned server storage as backup storage at no additional cost. 超出的备份存储使用量按每月每 GB 标准收费。Any additional backup storage used is charged in GB per month. 例如,如果为服务器配置了 250 GB 的存储空间,则可以为服务器备份提供 250 GB 的额外存储空间,而不另外收费。For example, if you have provisioned a server with 250 GB of storage, you have 250 GB of additional storage available for server backups at no additional charge. 备份所消耗的存储量超过 250GB 将按照定价模型收费。Storage consumed for backups more than 250 GB is charged as per the pricing model.

可以通过使用 Azure 门户中提供的 Azure Monitor 中的已使用的备份存储指标来监视服务器使用的备份存储。You can use the Backup Storage used metric in Azure Monitor available via the Azure portal to monitor the backup storage consumed by a server. 使用的备份存储指标表示根据为服务器设置的备份保留期保留的所有完整数据库备份、差异备份和日志备份所消耗的存储的总和。The Backup Storage used metric represents the sum of storage consumed by all the full database backups, differential backups, and log backups retained based on the backup retention period set for the server. 备份的频率由服务进行管控,已在前面进行了说明。The frequency of the backups is service managed and explained earlier. 无论数据库的总大小如何,如果服务器上的事务性活动繁重,都会导致备份存储使用率增加。Heavy transactional activity on the server can cause backup storage usage to increase irrespective of the total database size. 对于异地冗余存储,备份存储使用率是本地冗余存储的两倍。For geo-redundant storage, backup storage usage is twice that of the locally redundant storage.

控制备份存储成本的主要方法是设置适当的备份保留期,并选择正确的备份冗余选项以满足恢复目标。The primary means of controlling the backup storage cost is by setting the appropriate backup retention period and choosing the right backup redundancy options to meet your desired recovery goals. 可以选择 7 到 35 天的保留期。You can select a retention period from a range of 7 to 35 days. 常规用途和内存优化服务器可以选择使用异地冗余存储进行备份。General Purpose and Memory Optimized servers can choose to have geo-redundant storage for backups.

还原Restore

在 Azure Database for MySQL 中进行还原时,会根据原始服务器的备份创建新的服务器并还原服务器中包含的所有数据库。In Azure Database for MySQL, performing a restore creates a new server from the original server's backups and restores all databases contained in the server.

可以使用两种类型的还原:There are two types of restore available:

  • 时间点还原可通过任一备份冗余选项使用,并利用完整备份和事务日志备份的组合在原始服务器所在区域中创建一个新服务器。Point-in-time restore is available with either backup redundancy option and creates a new server in the same region as your original server utilizing the combination of full and transaction log backups.
  • 异地还原仅在你为服务器配置了异地冗余存储时可用,它允许你利用最近进行的备份将服务器还原到其他区域。Geo-restore is available only if you configured your server for geo-redundant storage and it allows you to restore your server to a different region utilizing the most recent backup taken.

估计的恢复时间取决于若干因素,包括数据库大小、事务日志大小、网络带宽,以及在同一区域同时进行恢复的数据库总数。The estimated time of recovery depends on several factors including the database sizes, the transaction log size, the network bandwidth, and the total number of databases recovering in the same region at the same time. 恢复时间通常少于 12 小时。The recovery time is usually less than 12 hours.

重要

已删除的服务器无法还原。Deleted servers cannot be restored. 如果删除服务器,则属于该服务器的所有数据库也会被删除且不可恢复。If you delete the server, all databases that belong to the server are also deleted and cannot be recovered. 为了防止服务器资源在部署后遭意外删除或意外更改,管理员可以利用管理锁To protect server resources, post deployment, from accidental deletion or unexpected changes, administrators can leverage management locks.

时间点还原Point-in-time restore

可以还原到备份保留期中的任意时间点,不管备份冗余选项如何。Independent of your backup redundancy option, you can perform a restore to any point in time within your backup retention period. 新服务器在原始服务器所在的 Azure 区域中创建。A new server is created in the same Azure region as the original server. 它在创建时,使用原始服务器在定价层、计算的代、vCore 数、存储大小、备份保留期和备份冗余选项方面的配置。It is created with the original server's configuration for the pricing tier, compute generation, number of vCores, storage size, backup retention period, and backup redundancy option.

备注

还原操作完成后,有两个服务器参数重置为默认值(而不是从主服务器复制)There are two server parameters which are reset to default values (and are not copied over from the primary server) after the restore operation

  • time_zone - 此值设置为默认值“SYSTEM”time_zone - This value to set to DEFAULT value SYSTEM
  • event_scheduler - 还原的服务器上的 event_scheduler 设置为“OFF”event_scheduler - The event_scheduler is set to OFF on the restored server

需要通过重新配置服务器参数来设置这些服务器参数You will need to set these server parameters by reconfiguring the server parameter

多种情况下可以使用时间点还原。Point-in-time restore is useful in multiple scenarios. 例如,用户意外删除了数据、删除了重要的表或数据库,或者应用程序因为缺陷而意外地使用错误数据覆盖了正确数据。For example, when a user accidentally deletes data, drops an important table or database, or if an application accidentally overwrites good data with bad data due to an application defect.

可能需要等到下一个事务日志备份进行后,才能还原到上一个五分钟内的某个时间点。You may need to wait for the next transaction log backup to be taken before you can restore to a point in time within the last five minutes.

异地还原Geo-restore

如果已将服务器配置为进行异地冗余备份,则可将服务器还原到另一 Azure 区域,只要服务在该区域可用即可。You can restore a server to another Azure region where the service is available if you have configured your server for geo-redundant backups. 查看 Azure Database for MySQL 定价层,以获取受支持区域的列表。Review Azure Database for MySQL pricing tiers for the list of supported regions.

当服务器因其所在的区域发生事故而不可用时,异地还原是默认的恢复选项。Geo-restore is the default recovery option when your server is unavailable because of an incident in the region where the server is hosted. 如果区域中出现的大规模事件导致数据库应用程序不可用,可以根据异地冗余备份将服务器还原到任何其他区域中的服务器。If a large-scale incident in a region results in unavailability of your database application, you can restore a server from the geo-redundant backups to a server in any other region. 异地还原利用服务器的最新备份。Geo-restore utilizes the most recent backup of the server. 提取备份后,会延迟一段时间才会将其复制到其他区域中。There is a delay between when a backup is taken and when it is replicated to different region. 此延迟可能长达一小时,因此发生灾难时,会有长达 1 小时的数据丢失风险。This delay can be up to an hour, so, if a disaster occurs, there can be up to one hour data loss.

在异地还原过程中,可以更改的服务器配置包括计算的代、vCore、备份保持期和备份冗余选项。During geo-restore, the server configurations that can be changed include compute generation, vCore, backup retention period, and backup redundancy options. 不支持在异地还原过程中更改定价层(“基本”、“常规用途”或“内存优化”)或存储大小。Changing pricing tier (Basic, General Purpose, or Memory Optimized) or storage size during geo-restore is not supported.

执行还原后任务Perform post-restore tasks

从任一恢复机制还原后,都应执行以下任务,然后用户和应用程序才能重新运行:After a restore from either recovery mechanism, you should perform the following tasks to get your users and applications back up and running:

  • 如果需要使用新服务器来替换原始服务器,则请将客户端和客户端应用程序重定向到新服务器If the new server is meant to replace the original server, redirect clients and client applications to the new server
  • 对于要进行连接的用户,请确保设置适当的 VNet 规则。Ensure appropriate VNet rules are in place for users to connect. 不会从源服务器复制这些规则。These rules are not copied over from the original server.
  • 确保设置适当的登录名和数据库级权限Ensure appropriate logins and database level permissions are in place
  • 视情况配置警报Configure alerts, as appropriate

后续步骤Next steps