Performing Database Recovery

Objectives

After completing this lesson, you will be able to:

  • Recover a database

Recovery of Tenant Databases

An SAP HANA database can be recovered using data backups and log backups. SAP HANA allows you to recover the SYSTEMDB and its tenant databases. The system database and tenant database can be recovered individually in the same system (recovery) or in a different system type (system copy). For a recovery, the source database and target database must have identical configurations.

A recovery of the SYSTEMDB or a tenant may be needed if there is a disk crash of the data or log area, if there is the need to reset a tenant to a specific point in time, or if there is a need for creating a database copy.

SAP HANA supports the following database recovery procedures:

  • Recovery to status before failure

  • Point-in-time recovery

  • Recovery to a specific data backup

Reasons to Recover the Database

Hardware failures or user errors are the main reasons that might require a database restore, and are explained in the following list:

(1) Data volume is unusable

If the data area is unusable, and all the data changes after the last complete data backup are still available in the log backups and log area, you can recover the data from committed transactions that was in-memory at the time of failure.

No committed data is lost.

For recovery, the data backups, the log backups, and the log area are used. When you restore the data backup successfully, the log entries from the log backups and the log area are replayed automatically.

You can also recover the database using an older data backup and log backups. All relevant log backups made after the data backup are needed for the recovery.

For more information, see SAP Note 1705945: Determining the files needed for a recovery.

(2) Log volume is unusable

If the log area is unusable, you can only replay the log backups. Therefore, any changes that are made after the most recent log backup are lost. In addition, all the transactions that were open during the log backup are rolled back.

You can still recover the database to a point in time within the existing log backups.

For recovery, the data backups and the log backups are used. When the data backup is successfully restored, the log entries from the log backups are automatically replayed. To prevent the recovery of entries from the unusable log area, in the Recovery Wizard, specify the Initialize log area option.

(3) Logical Error: Point in Time recovery

To reset the database to a particular point in time, you need a data backup from before the point in time to recover to, the subsequent log backups, and the log area.

All changes made after the recovery time are lost. If you perform this recovery, consider recovering the database to a different system.

Recovery Types

When a database has crashed due to hardware errors of user error, the database administrator need to restore the database to a consistent state.

The following recovery types are available:

(A) Recover the database to its most recent state

This option recovers the database to as close as possible to the current time.

This recovery option uses the following data:

  • The most recent data backup

  • Log backups made since the most recent data backup

  • Log area

(B) Recover the database to a specific point in time

This recovery option uses the following data:

  • The last data backup available before the specified point in time

  • Log backups made since the data backup to be used

  • Log area

(C) Recover the database to a specific data backup

This recovery option uses the following data:

The specified data backup

Note
Option (C) is not supported for delta backups. Log entries are not replayed, neither from the log backups nor from the log area. All log entries that still exist in the log area are deleted.

Requirements for Performing a Recovery

  • SAP HANA database must be shut down

  • User must have the system privilege BACKUP ADMIN

  • The <sid>adm operating system user is required

  • At least one data backup is required

  • Before a recovery can start, all data and log backups must be either accessible in the file system or available through the third-party backup tool

  • The number and type of services in source and target systems must be identical

  • To recover customer-specific configuration settings, configure the customer-specific settings before starting the recovery

Note
In SAP HANA, you can restore a backup from an older SAP HANA database version into a newer database version.

Performing an SAP HANA Database Recovery

A recovery typically consists of the following phases:

  1. Data recovery - complete data backup + delta backups
  2. Log replay - log backups + log entries from the log area
  3. Restart

To perform an SAP HANA database recovery, the following requirements must be met:

  • The SAP HANA database software must be installed, so that an initial database exists. In a recovery situation, you can use the SAP HANA cockpit to restore customer-specific changes to this initial database.

    Note that if you want to restore customer-specific configuration settings, you can do this either before you restore the database and the log backups, or at the end of the recovery.

  • Ensure that the target system and the source system have identical configurations. The number and types of services (for example, index server) on each host must be identical for both system landscapes.

  • At the beginning of a recovery, all the data and log backups to be used must be either accessible in the file system or available through the third-party backup tool.

  • At least one data backup must be available before the recovery is started.

  • To restore the database to a particular point in time, you need a data backup and all the log backups up to the point in time for recovery (including the log backups made after the desired point in time of the recovery).

Note

To recover the SAP HANA database, the database needs to be shut down. For this reason, during recovery, the database cannot be accessed by end users or applications.

Database Recovery

Prerequisites for a Database Recovery

  • The SAP HANA database software is installed on the target system.

  • To perform a recovery, an SAP HANA database needs to be shut down.

  • The following must be available:
    • At least one full backup (complete data backup or data snapshot)
    • If required, delta backups created since the full backup to be used
    • If required, log backups created since the full backup to be used

      (Covering changes not already contained in the delta backups)

    • If required, the log area

Points to Note

  • The recovery of a tenant database is always initiated from the system database. If tenant databases need to be recovered, they are recovered individually, and not all together in one single operation.

  • The system database only needs to be recovered if it is corrupted. If only a tenant database is corrupted, the system database does not need to be recovered.

  • If the system database is shut down for recovery, all its tenant databases are automatically shut down as well.

  • When an SAP HANA multitenant database container is recovered, the services needed are generated automatically in the tenant databases.

  • To recover a complete SAP HANA system, the system database needs to be recovered first, and then all the tenant databases are recovered individually.

Recovering a Tenant Database

  • Tenant databases are recovered individually, and not all together in one single operation.

  • Recovery of tenant databases can only be initiated from the system database.

  • You need the logon credentials of the system database user.
  • The system database and other tenant databases are not affected and remain online.

Recovering the System Database

  • The whole system is shut down, including all tenant databases.

  • You need the logon credentials of the <sid>adm user.

  • After the system database is recovered and restarted, you can restart the tenant databases.

  • The content of the tenant databases is not affected by the system database recovery.

Note

If the system database is shut down for recovery, its tenant databases are shut down automatically as well. This means that, until the recovery of the system database is completed, all its tenant databases are unavailable.

A recovery of a tenant database may be required if, for example, a logical error occurred in the tenant database.

Recovery of a Database with SAP HANA Cockpit

The options to recover a database using SAP HANA cockpit are as follows:

  • To its most recent consistent state

  • To a specific point in time

Note

Using SAP HANA cockpit, only a tenant database can be recovered to a point in time. To recover a system database to a point in time, use the recoverSys.py tool.

To recover an SAP HANA database, perform the following steps:

  1. In the SAP HANA cockpit, choose the database to recover:

    • To recover a tenant database, select the tenant database from the Manage databases screen, and choose Recover tenant.

    • To recover the system database, choose Recover Database.

  2. Specify the recovery type from one of the following:

    • Recover the database to the most recent state.

    • Recover the database to a specified point in time.

  3. Specify the location of the most recent backup catalog.

    An overview of the available full backups is displayed.

  4. Select the complete data backup to be used for the recovery.

  5. Specify whether to use delta backups.

  6. If you are using backups that differ from those recorded in the backup catalog, specify their locations.

  7. Check whether the backups are available.

    Decide if SAP HANA checks before the recovery starts if all the backups are available and if they can be accessed.

  8. Specify whether to initialize the log area.

    If you initialize the log area, the content of the log area is lost. No log entries from the log area can be replayed during the recovery. The log entries from the log backups are replayed if they are needed.

    Initialize the log area when the log area is unusable or when you are recovering the database to a different system.

  9. Choose Review.

    An overview of the recovery settings displays.

    To change any settings, choose Edit. All the settings that you specified are retained until you change them.

  10. To display the SQL statement that is used for the recovery, choose Display SQL Statement.

  11. Choose Start Recovery.

    The progress of the recovery for each SAP HANA service displays.

When the recovery is complete, a message confirms this, and shows the timestamp to which the recovery was completed.

The database is restarted automatically after the recovery. The recovery features are as follows:

Automatic checks for file system backups at the start of a recovery

In addition to checking for missing backups at the start of a recovery, SAP HANA also checks file system backups for corruption automatically.

An example of a corruption is if the size or backup ID do not match with the information recorded in the backup catalog. If SAP HANA detects a corruption, the recovery is not started. The details are displayed in the recovery wizard and are written to the backup log file.

Note

The extended checks are executed for file system backups only. If a third-party backup tool is used, only the existence of the backups on the third-party backup server is verified.

Progress reporting for a recovery shows the recovery process in detail

After the initial collection of system information for the recovery, the recovery wizard shows the following phases (progress per service):

  • Phase 1: Data recovery

    Using data backup or snapshot

  • Phase 2: Log recovery

    Using log backups or log that is still available in the log area

  • Phase 3: Restart

Log in to track your progress & complete quizzes