如何使用 Azure 门户在 Azure Database for PostgreSQL(单一服务器)中备份和还原服务器How to backup and restore a server in Azure Database for PostgreSQL - Single Server using the Azure portal

自动进行备份Backup happens automatically

Azure Database for PostgreSQL 服务器定期进行备份以便启用还原功能。Azure Database for PostgreSQL servers are backed up periodically to enable Restore features. 通过此功能,用户可将服务器及其所有数据库还原到新服务器上的某个较早时间点。Using this feature you may restore the server and all its databases to an earlier point-in-time, on a new server.

设置备份配置Set backup configuration

创建服务器时,可以在“定价层” 窗口中选择将服务器配置为进行本地冗余备份或异地冗余备份。You make the choice between configuring your server for either locally redundant backups or geographically redundant backups at server creation, in the Pricing Tier window.

Note

创建服务器后,无法在异地冗余或本地冗余之间切换服务器冗余类型。After a server is created, the kind of redundancy it has, geographically redundant vs locally redundant, can't be switched.

通过 Azure 门户创建服务器时,在“定价层” 窗口中为服务器选择是进行本地冗余备份还是异地冗余备份。While creating a server through the Azure portal, the Pricing Tier window is where you select either Locally Redundant or Geographically Redundant backups for your server. 也在此窗口中选择“备份保留期” - 希望存储服务器备份多长时间(天数)。This window is also where you select the Backup Retention Period - how long (in number of days) you want the server backups stored for.

定价层 - 选择备份冗余

有关在创建过程中设置这些值的详细信息,请参阅 Azure Database for PostgreSQL 服务器快速入门For more information about setting these values during create, see the Azure Database for PostgreSQL server quickstart.

可以通过以下步骤更改服务器的备份保留期:The backup retention period of a server can be changed through the following steps:

  1. 登录到 Azure 门户Sign into the Azure portal.

  2. 选择你的 Azure Database for PostgreSQL 服务器。Select your Azure Database for PostgreSQL server. 此操作将打开“概述” 页。This action opens the Overview page.

  3. 在“设置” 下,从菜单中选择“定价层” 。Select Pricing Tier from the menu, under SETTINGS. 使用滑块可以根据需要更改备份保留期(7 天到 35 天)。Using the slider you can change the Backup Retention Period to your preference between 7 and 35 days. 在下面的屏幕截图中,该项已增加到 34 天。In the screenshot below it has been increased to 34 days. 增加的备份保留期Backup retention period increased

  4. 单击“确定” 确认更改。Click OK to confirm the change.

备份保留期控制可以往回检索多长时间的时间点还原,因为它基于可用备份。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. 以下部分进一步说明了时间点还原。Point-in-time restore is described further in the following section.

时间点还原Point-in-time restore

使用 Azure Database for PostgreSQL 可以将服务器还原到某个时间点,并还原到服务器的新副本。Azure Database for PostgreSQL allows you to restore the server back to a point-in-time and into to a new copy of the server. 可以使用此新服务器恢复数据,或将客户端应用程序指向此新服务器。You can use this new server to recover your data, or have your client applications point to this new server.

例如,如果今天中午不小心删除了一张表,则可以将该表还原到中午之前的状态,并从服务器的新副本中检索丢失的表和数据。For example, if a table was accidentally dropped at noon today, you could restore to the time just before noon and retrieve the missing table and data from that new copy of the server. 时间点还原在服务器级别(而不是在数据库级别)进行。Point-in-time restore is at the server level, not at the database level.

以下步骤演示将示例服务器还原到某个时间点:The following steps restore the sample server to a point-in-time:

  1. 在 Azure 门户中,选择 Azure Database for PostgreSQL 服务器。In the Azure portal, select your Azure Database for PostgreSQL server.

  2. 在服务器“概述”页的工具栏中,选择“还原” 。In the toolbar of the server's Overview page, select Restore.

    Azure Database for PostgreSQL - 概述 - 还原按钮

  3. 使用必需信息填写“还原”窗体:Fill out the Restore form with the required information:

    Azure Database for PostgreSQL - 还原信息

    • 还原点:选择要还原到的时间点。Restore point: Select the point-in-time you want to restore to.
    • 目标服务器:提供新服务器的名称。Target server: Provide a name for the new server.
    • 位置:不可选择区域。Location: You cannot select the region. 默认情况下,此值与源服务器相同。By default it is same as the source server.
    • 定价层:执行时间点还原时,无法更改这些参数。Pricing tier: You cannot change these parameters when doing a point-in-time restore. 此值与源服务器相同。It is same as the source server.
  4. 单击“确定” ,将服务器还原到某个时间点。Click OK to restore the server to restore to a point-in-time.

  5. 还原完成后,找到创建的新服务器,以验证数据是否已按预期还原。Once the restore finishes, locate the new server that is created to verify the data was restored as expected.

Note

通过时间点还原创建的新服务器具有在所选时间点对现有服务器有效的相同服务器管理员登录名和密码。The new server created by point-in-time restore has the same server admin login name and password that was valid for the existing server at the point-in-time chose. 可以从新服务器的“概述” 页更改密码。You can change the password from the new server's Overview page.

异地还原Geo restore

如果为服务器配置了异地冗余备份,则可以从该现有服务器的备份创建新服务器。If you configured your server for geographically redundant backups, a new server can be created from the backup of that existing server. 可以在 Azure Database for PostgreSQL 可用的任何区域中创建此新服务器。This new server can be created in any region that Azure Database for PostgreSQL is available.

  1. 选择门户左上角的“创建资源”按钮 (+) 。Select the Create a resource button (+) in the upper-left corner of the portal. 选择“数据库” > “Azure Database for PostgreSQL”。Select Databases > Azure Database for PostgreSQL.

    “用于 PostgreSQL 的 Azure 数据库”选项

  2. 在窗体的“选择源” 下拉列表中,选择“备份” 。In the form's Select Source dropdown, choose Backup. 此操作将加载已启用异地冗余备份的服务器列表。This action loads a list of servers that have geo redundant backups enabled. 选择这些备份之一作为新服务器的源。Select one of these backups to be the source of your new server. 选择源:备份和异地冗余备份的列表Select Source: Backup and list of geo redundant backups

    Note

    首次创建服务器时,该服务器可能不会立即可用于异地还原。When a server is first created it may not be immediately available for geo restore. 填充必需的元数据可能需要几个小时。It may take a few hours for the necessary metadata to be populated.

  3. 根据需要填写窗体的其余部分。Fill out the rest of the form with your preferences. 可以选择任意位置You can select any Location. 选择位置后,可以选择定价层After selecting the location, you can select Pricing Tier. 默认情况下将显示要从中还原的现有服务器的参数。By default the parameters for the existing server you are restoring from are displayed. 可以单击“确定” ,以不进行任何更改继承这些设置。You can click OK without making any changes to inherit those settings. 也可以更改计算的代(如果在所选区域中可用)、vCore 数、备份保留期备份冗余选项Or you can change Compute Generation (if available in the region you have chosen), number of vCores, Backup Retention Period, and Backup Redundancy Option. 不支持在还原过程中更改定价层(“基本”、“常规用途”或“内存优化”)或存储大小。Changing Pricing Tier (Basic, General Purpose, or Memory Optimized) or Storage size during restore is not supported.

Note

通过异地还原创建的新服务器具有在启动还原时对现有服务器有效的相同服务器管理员登录名和密码。The new server created by geo restore has the same server admin login name and password that was valid for the existing server at the time the restore was initiated. 可以从新服务器的“概述” 页更改密码。The password can be changed from the new server's Overview page.

后续步骤Next steps