还原 Azure VM 上的 SAP HANA 数据库Restore SAP HANA databases on Azure VMs

本文介绍如何还原在 Azure 虚拟机 (VM) 上运行的、已由 Azure 备份服务备份到恢复服务保管库的 SAP HANA 数据库。This article describes how to restore SAP HANA databases running on an Azure Virtual Machine (VM), which the Azure Backup service has backed up to a Recovery Services vault. 可以通过还原来为开发/测试方案创建数据的副本,或返回到以前的状态。Restores can be used to create copies of the data for dev / test scenarios or to return to a previous state.

有关如何备份 SAP HANA 数据库的详细信息,请参阅备份 Azure VM 上的 SAP HANA 数据库For more information, on how to back up SAP HANA databases, see Back up SAP HANA databases on Azure VMs.

还原到某个时间点或恢复点Restore to a point in time or to a recovery point

Azure 备份可以还原在 Azure VM 上运行的 SAP HANA 数据库,如下所示:Azure Backup can restore SAP HANA databases that are running on Azure VMs as follows:

  • 使用日志备份还原到特定的日期或时间(精确到秒)。Restore to a specific date or time (to the second) by using log backups. Azure 备份可自动确定相应的完整备份、差异备份和日志链备份,这些是根据所选时间进行还原所必需的。Azure Backup automatically determines the appropriate full, differential backups and the chain of log backups that are required to restore based on the selected time.

  • 还原特定的完整备份或差异备份,这样就可以还原到特定的恢复点。Restore to a specific full or differential backup to restore to a specific recovery point.

先决条件Prerequisites

在还原数据库之前,请注意以下事项:Before restoring a database, note the following:

  • 只能将数据库还原到同一区域中的 SAP HANA 实例You can restore the database only to an SAP HANA instance that is in the same region

  • 目标实例必须注册到与源相同的保管库The target instance must be registered with the same vault as the source

  • Azure 备份不能识别同一 VM 上两个不同的 SAP HANA 实例。Azure Backup can't identify two different SAP HANA instances on the same VM. 因此,无法将数据从同一 VM 上的一个实例还原到另一个实例。So restoring data from one instance to another on the same VM isn't possible.

  • 若要确保目标 SAP HANA 实例已准备好进行还原,请检查其备份就绪情况状态:To ensure that the target SAP HANA instance is ready for restore, check its Backup readiness status:

    1. 打开在其中注册目标 SAP HANA 实例的保管库Open the vault in which the target SAP HANA instance is registered

    2. 在保管库仪表板上,在“开始使用” 下选择“备份” On the vault dashboard, under Getting started, choose Backup

      保管库仪表板中的备份

    3. 在“备份” 中,在“你希望备份什么?” 下选择“Azure VM 中的 SAP HANA” In Backup, under What do you want to backup? choose SAP HANA in Azure VM

      选择“Azure VM 中的 SAP HANA”

    4. 在“发现 VM 中的 DB”下,单击“查看详细信息” Under Discover DBs in VMs, click on View details

      查看详细信息

    5. 查看目标 VM 的备份就绪情况Review the Backup Readiness of the target VM

      受保护的服务器

  • 若要详细了解 SAP HANA 支持的还原类型,请参阅 SAP HANA 说明 1642148To learn more about the restore types that SAP HANA supports, refer to the SAP HANA Note 1642148

还原数据库Restore a database

若要进行还原,需要以下权限:To restore, you need the following permissions:

  • 在其中执行还原的保管库中的“备份操作员”权限。Backup Operator permissions in the vault where you're doing the restore.
  • 对已备份的源 VM 的参与者(写入) 访问权限。Contributor (write) access to the source VM that's backed up.
  • 对目标 VM 的参与者(写入)访问权限:Contributor (write) access to the target VM:
    • 若要还原到同一 VM,则此项将是源 VM。If you're restoring to the same VM, this is the source VM.
    • 若要还原到备用位置,则此项将是新的目标 VM。If you're restoring to an alternate location, this is the new target VM.
  1. 打开要在其中注册要还原的 SAP HANA 数据库的保管库Open the vault in which the SAP HANA database to be restored is registered

  2. 在保管库项仪表板上,在“受保护的项”下,选择“备份项”On the vault dashboard, under Protected Items, choose Backup Items

    备份项

  3. 在“备份项”中,在“备份管理类型”下,选择“Azure VM 中的 SAP HANA”。 In Backup Items, under Backup Management Type select SAP HANA in Azure VM

    备份管理类型

  4. 选择要还原的数据库。Select the database to be restored

    要还原的数据库

  5. 查看数据库菜单。Review the database menu. 它提供有关数据库备份的信息,包括:It provides information about database backup, including:

    • 最旧和最新的还原点The oldest and latest restore points

    • 数据库过去 24 小时和 72 小时的日志备份状态The log backup status for the last 24 and 72 hours for the database

    数据库菜单

  6. 选择“还原数据库”Select Restore DB

  7. 在“还原配置”下,指定要将数据还原到何处(或如何还原):Under Restore Configuration, specify where (or how) to restore data:

    • 备用位置:将数据库还原到备用位置,同时保留原始源数据库。Alternate Location: Restore the database to an alternate location and keep the original source database.

    • 覆盖 DB:将数据还原到原始源所在的同一 SAP HANA 实例。Overwrite DB: Restore the data to the same SAP HANA instance as the original source. 此选项将覆盖原始数据库。This option overwrites the original database.

      还原配置

还原到备用位置Restore to alternate location

  1. 在“还原配置”菜单中的“还原位置”下,选择“备用位置”。 In the Restore Configuration menu, under Where to Restore, select Alternate Location.

    还原到备用位置

  2. 选择要将数据库还原到其中的 SAP HANA 主机名和实例。Select the SAP HANA host name and instance name to which you want to restore the database.

  3. 通过查看目标 SAP HANA 实例的备份就绪情况状态,检查其是否已准备好进行还原。Check if the target SAP HANA instance is ready for restore by ensuring its Backup Readiness. 有关更多详细信息,请参阅先决条件部分Refer to the prerequisites section for more details.

  4. 在“还原数据库名称”框中,输入目标数据库的名称。In the Restored DB Name box, enter the name of the target database.

    备注

    单一数据库容器 (SDC) 还原必须遵循这些检查项Single Database Container (SDC) restores must follow these checks.

  5. 如果适用,请选择“当选定的 HANA 实例上已存在同名的 DB 时覆盖”。If applicable, select Overwrite if the DB with the same name already exists on selected HANA instance.

  6. 选择“确定” 。Select OK.

    还原配置 - 最终屏幕

  7. 在“选择还原点”中选择“日志(时间点)”,以还原到特定的时间点In Select restore point, select Logs (Point in Time) to restore to a specific point in time. 或者选择“完整和差异”以还原到特定的恢复点Or select Full & Differential to restore to a specific recovery point.

还原并覆盖Restore and overwrite

  1. 在“还原配置”菜单中的“还原位置”下,选择“覆盖数据库” > “确定”。 In the Restore Configuration menu, under Where to Restore, select Overwrite DB > OK.

    覆盖 DB

  2. 在“选择还原点”中选择“日志(时间点)”,以还原到特定的时间点In Select restore point, select Logs (Point in Time) to restore to a specific point in time. 或者选择“完整和差异”以还原到特定的恢复点Or select Full & Differential to restore to a specific recovery point.

作为文件还原Restore as files

若要将备份数据作为文件而不是数据库还原,请选择“作为文件还原”。To restore the backup data as files instead of a database, choose Restore as Files. 文件转储到指定路径后,可以将这些文件移动到要将其还原为数据库的任何 SAP HANA 计算机上。Once the files are dumped to a specified path, you can take these files to any SAP HANA machine where you want to restore them as a database. 由于可以将这些文件移动到任何计算机,你现在可以跨订阅和区域进行数据还原。Because you can move these files to any machine, you can now restore the data across subscriptions and regions.

  1. 在“还原配置”菜单中的“还原位置及还原方式”下,选择“作为文件还原” 。In the Restore Configuration menu, under Where and how to Restore, select Restore as files.

  2. 选择要将备份还原到的主机/HANA Server 的名称。Select the host / HANA Server name to which you want to restore the backup files.

  3. 在“服务器上的目标路径”中,输入在步骤 2 中选择的服务器上的文件夹路径。In the Destination path on the server, enter the folder path on the server selected in step 2. 此位置是服务要将全部所需备份文件转储到的位置。This is the location where the service will dump all the necessary backup files.

    转储的文件包括:The files that are dumped are:

    • 数据库备份文件Database backup files
    • 目录文件Catalog files
    • JSON 元数据文件(适用于所涉及的每个备份文件)JSON metadata files (for each backup file that is involved)

    通常,如果将网络共享路径或已装载的 Azure 文件共享的路径指定为目标路径,会使同一网络中的其他计算机或其上装载的同一 Azure 文件共享更加轻松地访问这些文件。Typically, a network share path, or path of a mounted Azure file share when specified as the destination path, enables easier access to these files by other machines in the same network or with the same Azure file share mounted on them.

    备注

    要在装载在目标注册的 VM 上的 Azure 文件共享上还原数据库备份文件,请确保根帐户对 Azure 文件共享具有读/写权限。To restore the database backup files on an Azure file share mounted on the target registered VM, make sure that root account has read/ write permissions on the Azure file share.

    选择目标路径

  4. 选择要与所有备份文件和文件夹还原到的状态相对应的还原点。Select the Restore Point corresponding to which all the backup files and folders will be restored.

    选择还原点

  5. 与所选还原点关联的所有备份文件将转储到目标路径中。All the backup files associated with the selected restore point are dumped into the destination path.

  6. 根据所选的还原点类型(“时间点”或“完整和差异”),你将看到一个或多个在目标路径中创建的文件夹 。Based on the type of restore point chosen (Point in time or Full & Differential), you'll see one or more folders created in the destination path. 名为 Data_<date and time of restore> 的文件夹之一包含完整备份和差异备份,名为 Log 的其他文件夹包含日志备份。One of the folders named Data_<date and time of restore> contains the full and differential backups, and the other folder named Log contains the log backups.

  7. 将这些已还原文件移动到要将其还原为数据库的 SAP HANA 服务器。Move these restored files to the SAP HANA server where you want to restore them as a database.

  8. 然后执行以下步骤:Then follow these steps:

    1. 使用以下命令在存储备份文件的文件夹/目录上设置权限:Set permissions on the folder / directory where the backup files are stored using the following command:

      chown -R <SID>adm:sapsys <directory>
      
    2. 运行下一组命令 <SID>admRun the next set of commands as <SID>adm

      su - <sid>adm
      
    3. 生成用于还原的目录文件。Generate the catalog file for restore. 从用于完整备份的 JSON 元数据文件中提取“BackupId”,稍后将在还原操作中使用它。Extract the BackupId from the JSON metadata file for the full backup, which will be used later in the restore operation. 请确保完整备份和日志备份位于不同的文件夹中,并删除这些文件夹中的目录文件和 JSON 元数据文件。Make sure that the full and log backups are in different folders and delete the catalog files and JSON metadata files in these folders.

      hdbbackupdiag --generate --dataDir <DataFileDir> --logDirs <LogFilesDir> -d <PathToPlaceCatalogFile>
      

      在上面的命令中:In the above command:

      • <DataFileDir> - 包含完整备份的文件夹<DataFileDir> - the folder that contains the full backups
      • <LogFilesDir> - 包含日志备份的文件夹<LogFilesDir> - the folder that contains the log backups
      • <PathToPlaceCatalogFile> - 必须放置已生成的目录文件的文件夹<PathToPlaceCatalogFile> - the folder where the catalog file generated must be placed
    4. 通过 HANA Studio 使用新生成的目录文件进行还原或使用此新生成的目录运行 HDBSQL 还原查询。Restore using the newly generated catalog file through HANA Studio or run the HDBSQL restore query with this newly generated catalog. 下面列出了 HDBSQL 查询:HDBSQL queries are listed below:

    • 要还原到一个时间点:To restore to a point in time:

      如果要创建新的已还原数据库,请运行 HDBSQL 命令,以创建新的数据库 <DatabaseName>,然后停止用于还原的数据库。If you're creating a new restored database, run the HDBSQL command to create a new database <DatabaseName> and then stop the database for restore. 但是,如果只是还原现有数据库,请运行 HDBSQL 命令以停止数据库。However, if you're only restoring an existing database, run the HDBSQL command to stop the database.

      然后运行以下命令以还原数据库:Then run the following command to restore the database:

      RECOVER DATABASE FOR <DatabaseName> UNTIL TIMESTAMP '<TimeStamp>' CLEAR LOG USING SOURCE '<DatabaseName@HostName>'  USING CATALOG PATH ('<PathToGeneratedCatalogInStep3>') USING LOG PATH (' <LogFileDir>') USING DATA PATH ('<DataFileDir>') USING BACKUP_ID <BackupIdFromJsonFile> CHECK ACCESS USING FILE
      
      • <DatabaseName> - 新数据库或要还原的现有数据库的名称<DatabaseName> - Name of the new database or existing database that you want to restore
      • <Timestamp> - 时间点还原的确切时间戳<Timestamp> - Exact timestamp of the Point in time restore
      • <DatabaseName@HostName> - 备份用于还原的数据库的名称,以及此数据库所在位置的“主机”/SAP HANA 服务器的名称。<DatabaseName@HostName> - Name of the database whose backup is used for restore and the host / SAP HANA server name on which this database resides. USING SOURCE <DatabaseName@HostName> 选项指定数据备份(用于还原)是一个具有与目标 SAP HANA 计算机不同的 SID 或名称的数据库。The USING SOURCE <DatabaseName@HostName> option specifies that the data backup (used for restore) is of a database with a different SID or name than the target SAP HANA machine. 因此,对于在进行备份的 HANA 服务器上进行的还原,不需要指定它。So it doesn't need be specified for restores done on the same HANA server from where the backup is taken.
      • <PathToGeneratedCatalogInStep3> - 在“步骤 C”中生成的指向目录文件的路径<PathToGeneratedCatalogInStep3> - Path to the catalog file generated in Step C
      • <DataFileDir> - 包含完整备份的文件夹<DataFileDir> - the folder that contains the full backups
      • <LogFilesDir> - 包含日志备份的文件夹<LogFilesDir> - the folder that contains the log backups
      • <BackupIdFromJsonFile> - 在“步骤 C”中提取的“BackupId” <BackupIdFromJsonFile> - the BackupId extracted in Step C
    • 要还原到特定完整备份或差异备份:To restore to a particular full or differential backup:

      如果要创建新的已还原数据库,请运行 HDBSQL 命令,以创建新的数据库 <DatabaseName>,然后停止用于还原的数据库。If you're creating a new restored database, run the HDBSQL command to create a new database <DatabaseName> and then stop the database for restore. 但是,如果只是还原现有数据库,请运行 HDBSQL 命令来停止数据库:However, if you're only restoring an existing database, run the HDBSQL command to stop the database:

      RECOVER DATA FOR <DatabaseName> USING BACKUP_ID <BackupIdFromJsonFile> USING SOURCE '<DatabaseName@HostName>'  USING CATALOG PATH ('<PathToGeneratedCatalogInStep3>') USING DATA PATH ('<DataFileDir>')  CLEAR LOG
      
      • <DatabaseName> - 新数据库或要还原的现有数据库的名称<DatabaseName> - the name of the new database or existing database that you want to restore
      • <Timestamp> - 时间点还原的确切时间戳<Timestamp> - the exact timestamp of the Point in time restore
      • <DatabaseName@HostName> - 备份用于还原的数据库的名称,以及此数据库所在位置的“主机”/SAP HANA 服务器的名称。<DatabaseName@HostName> - the name of the database whose backup is used for restore and the host / SAP HANA server name on which this database resides. USING SOURCE <DatabaseName@HostName> 选项指定数据备份(用于还原)是一个具有与目标 SAP HANA 计算机不同的 SID 或名称的数据库。The USING SOURCE <DatabaseName@HostName> option specifies that the data backup (used for restore) is of a database with a different SID or name than the target SAP HANA machine. 因此,不需要为采用备份的同一 HANA 服务器上的还原指定它。So it need not be specified for restores done on the same HANA server from where the backup is taken.
      • <PathToGeneratedCatalogInStep3> - 在“步骤 C”中生成的指向目录文件的路径<PathToGeneratedCatalogInStep3> - the path to the catalog file generated in Step C
      • <DataFileDir> - 包含完整备份的文件夹<DataFileDir> - the folder that contains the full backups
      • <LogFilesDir> - 包含日志备份的文件夹<LogFilesDir> - the folder that contains the log backups
      • <BackupIdFromJsonFile> - 在“步骤 C”中提取的“BackupId” <BackupIdFromJsonFile> - the BackupId extracted in Step C

还原到特定时间点Restore to a specific point in time

如果已选择“日志(时间点)”作为还原类型,请执行以下操作:If you've selected Logs (Point in Time) as the restore type, do the following:

  1. 从日志图中选择一个恢复点,然后选择“确定”以选择还原点。Select a recovery point from the log graph and select OK to choose the point of restore.

    还原点

  2. 在“还原”菜单中,选择“还原”启动还原作业。 On the Restore menu, select Restore to start the restore job.

    选择“还原”

  3. 在“通知”区域中跟踪还原进度,或者在数据库菜单中选择“还原作业”来跟踪进度。 Track the restore progress in the Notifications area or track it by selecting Restore jobs on the database menu.

    还原已成功触发

还原到特定的恢复点Restore to a specific recovery point

如果已选择“完整和差异”作为还原类型,请执行以下操作:If you've selected Full & Differential as the restore type, do the following:

  1. 从列表中选择一个恢复点,然后选择“确定”以选择还原点。Select a recovery point from the list and select OK to choose the point of restore.

    还原特定的恢复点

  2. 在“还原”菜单中,选择“还原”启动还原作业。 On the Restore menu, select Restore to start the restore job.

    开始还原作业

  3. 在“通知”区域中跟踪还原进度,或者在数据库菜单中选择“还原作业”来跟踪进度。 Track the restore progress in the Notifications area or track it by selecting Restore jobs on the database menu.

    还原进度

    备注

    在多数据库容器 (MDC) 还原中,在将系统数据库还原到目标实例之后,需要再次运行预注册脚本。In Multiple Database Container (MDC) restores after the system DB is restored to a target instance, one needs to run the pre-registration script again. 只有这样,随后的租户数据库还原才会成功。Only then the subsequent tenant DB restores will succeed. 若要了解详细信息,请参阅故障排除 - MDC 还原To learn more refer to Troubleshooting - MDC Restore.

后续步骤Next steps

  • 了解如何管理使用 Azure 备份进行备份的 SAP HANA 数据库Learn how to manage SAP HANA databases backed up using Azure Backup