Back up and recover SAP HANA by using disk snapshots

This guide shows you how to back up and recover your SAP HANA database by using the disk snapshot feature of Google Cloud's Agent for SAP.

For information about this feature, see Backup and recovery for SAP HANA by using disk snapshots.

Before you begin

Set permissions

To back up and recover your SAP HANA database by using the disk snapshot feature of Google Cloud's Agent for SAP, you must set the following permissions:

  • To create disk snapshots, grant the following IAM roles or permissions:
    • If your /hana/data volume is hosted on one Persistent Disk or Hyperdisk volume, then grant the following:
      • For the Google Cloud project where your SAP HANA system runs, enable the compute.snapshots.create permission.
      • For the service account used by your Compute Engine VM instance, enable the following permissions: compute.disks.createSnapshot, compute.snapshot.list, and compute.disk.list.
    • If your /hana/data volume is hosted on more than one disk, then grant the following permissions:
      • compute.disks.addResourcePolicies
      • compute.disks.removeResourcePolicies
      • compute.disks.get
      • compute.disks.create
      • compute.disks.use
      • compute.disks.useReadOnly
      • compute.globalOperations.get
      • compute.instances.get
      • compute.instances.attachDisk
      • compute.instances.detachDisk
      • compute.instantSnapshotGroups.create
      • compute.instantSnapshotGroups.delete
      • compute.instantSnapshotGroups.get
      • compute.instantSnapshots.list
      • compute.instantSnapshots.useReadOnly
      • compute.resourcePolicies.create
      • compute.resourcePolicies.use
      • compute.resourcePolicies.useReadOnly
      • compute.snapshots.create
      • compute.snapshots.get
      • compute.snapshots.list
      • compute.snapshots.setLabels
      • compute.snapshots.useReadOnly
      • compute.zoneOperations.get
  • To create disk snapshot based backups, the SAP HANA database user used by the agent must have the BACKUP OPERATOR or BACKUP ADMIN privilege. For more information, see the SAP document Authorizations Needed for Backup and Recovery
  • To back up and recover your SAP HANA database, the operating system user running the agent's commands must either be the root user, or have sudo access to run the following commands. You can also provide sudo access by creating a group in your /etc/sudoers.d directory, for example:

    %sapagent_snapshot_sudoers ALL=(ALL:ALL) NOPASSWD:/sbin/lvdisplay, /sbin/vgscan, /sbin/dmsetup, /sbin/lvscan, /usr/sbin/xfs_freeze, /usr/bin/google_cloud_sap_agent

Create a disk consistency group

If your /hana/data volume is hosted on one disk, then skip this section.

If your /hana/data volume is hosted on more than one disk, then you must create a consistency group and add the disks hosting your /hana/data volume to that consistency group. You must create the consistency group in the same region as the disks.

For information about how to do this, see Create a consistency group.

Make note of the consistency group name. It's used by the agent while creating the snapshot based backup.

Create a disk snapshot based backup

  • To create a disk snapshot based backup for the /hana/data volume of your SAP HANA database, run the hanadiskbackup command of Google Cloud's Agent for SAP:

    From version 3.3, the arguments -source-disk and -source-disk-zone are optional for use with the hanadiskbackup command. This is because the agent can auto-detect the disk that hosts your /hana/data directory. However, if you specify these arguments, then they override the agent's auto-detection.

    sudo /usr/bin/google_cloud_sap_agent hanadiskbackup \
        -project=DESTINATION_PROJECT_ID \
        -host=HANA_HOST_ADDRESS \
        -port=HANA_PORT_NUMBER \
        -sid=SID \
        -hana-db-user=HANA_USERNAME \
        -password-secret=HANA_USER_PWD_SECRET_NAME \
        -hdbuserstore-key=HDB_USERSTORE_KEY \
    

    Replace the following:

    • DESTINATION_PROJECT_ID: the ID of the Google Cloud project in which you want to create the disk snapshot
    • HANA_HOST_ADDRESS: the hostname or IP address of the Compute Engine VM instance that hosts your SAP HANA database

      In a high-availability (HA) system, specify the hostname or IP address of the local host in the primary SAP HANA node. Don't use the virtual IP (VIP) used in the cluster to identify the primary node. In a disaster recovery (DR) deployment, specify the hostname or IP address of the local host in the primary SAP HANA instance.

    • HANA_PORT_NUMBER: the SAP HANA port that accepts the backup and recovery requests

    • SID: the SAP system identifier (SID) of your SAP HANA system

    • HANA_USERNAME: the SAP HANA database username using which you want to create the backup

    • HANA_USER_PWD_SECRET_NAME: if you're using Secret Manager to store the SAP HANA database user's password, then specify the corresponding secret name

    • HDB_USERSTORE_KEY: if you've created an hdbuserstore key to authenticate the specified SAP HANA user, then specify that key

    The following table describes the arguments supported by the hanadiskbackup command:

    Argument Description
    -port Specify the SAP HANA port that accepts the backup and recovery requests.
    -sid Specify the SAP system identifier (SID) of your SAP HANA system.
    -hana-db-user

    Specify the SAP HANA database username using which you want to create the backup.

    If you specify -hdbuserstore-key, then you can skip specifying the -hana-db-user argument.

    -password

    Specify the password of the SAP HANA database user that you use to create the backup.

    Don't specify this argument if you're using the -password-secret or the -hdbuserstore-key argument. We recommend that you use either of them instead of using -password.

    -password-secret

    Optional. If you're using Secret Manager to store the SAP HANA database user's password, then specify the corresponding secret name.

    In Secret Manager, make sure that the Secret value, which is the password, contains at least 8 characters and includes at least one uppercase letter, one lowercase letter, and a number.

    Don't specify this argument if you're using the -password argument.

    -hdbuserstore-key

    To securely connect to an SAP HANA system, specify a Secure user store (hdbuserstore) key that you've created for that system.

    To use an hdbuserstore key for authentication, ensure the following:

    • The SAP tools hdbsql and hdbuserstore are installed on the compute instance hosting the agent.
    • The hdbuserstore key corresponds to one specific SAP HANA instance. You can't use keys that contain hostnames of multiple SAP HANA instances.
    • The SIDadm user can query the SAP HANA database using this key. Here SID refers to the value that you've specified for the sid parameter. You can verify this by running the following command as the SIDadm user:
      hdbsql -U HDB_USERSTORE_KEY "SELECT * FROM DUMMY"

    This configuration parameter is supported from version 3.3 of the agent.

    If you specify -hdbuserstore-key, then you can skip specifying the -host, -port, and -hana-db-user arguments.

    -host Optional. Specify the IP address of the Compute Engine VM instance that hosts your SAP HANA system. The default value is localhost.
    -project Optional. Specify the ID of the Google Cloud project where your SAP HANA instance is running.
    -abandon-prepared Optional. Specifies whether to ignore any existing snapshot based backup or not. The default value is false.
    -snapshot-name

    Optional. Specify the name for the disk snapshot that you're creating. This argument is applicable only when your /hana/data volume is hosted on one disk.

    By default, the snapshot is named by using the following format: snapshot-SOURCE_DISK_NAME-YYYYMMDD-HHMMSS.

    -snapshot-description Optional. Specify a description for the disk snapshot. This argument is applicable only when your /hana/data volume is hosted on one disk.
    -snapshot-type

    Optional. Specify the type of snapshots that you want to create for the disks hosting your /hana/data volume. This argument is applicable only when your /hana/data volume is hosted on more than one disk.

    By default, the agent creates standard snapshots. Supported values for this argument: STANDARD, ARCHIVE. For information about these snapshot types, see About archive and standard disk snapshots.

    This argument is supported from version 3.6 of the agent.

    -group-snapshot-name

    Optional. Specify the snapshot group name for the snapshots of the disks hosting your /hana/data volume.

    By default, the snapshot group name is set by using the following format: CONSISTENCY_GROUP_NAME-YYYYMMDD-HHMMSS. Here, CONSISTENCY_GROUP_NAME is the name of the disk consistency group that you created in the section Create a disk consistency group.

    This argument is supported from version 3.6 of the agent.

    -labels Optional. Specify one or more label-value pairs that you want to associate with the disk snapshots you're creating. For example: -labels="label1=value1,label2=value2".
    -source-disk Specify the name of the Persistent Disk or Hyperdisk volume that hosts your /hana/data volume.

    From version 3.3, the arguments -source-disk and -source-disk-zone are optional for use with the hanadiskbackup command. This is because the agent can auto-detect the disk that hosts your /hana/data directory. However, if you specify these arguments, then they override the agent's auto-detection.

    -source-disk-zone Specify the zone where the disk hosting the /hana/data volume exists.

    From version 3.3, the arguments -source-disk and -source-disk-zone are optional for use with the hanadiskbackup command. This is because the agent can auto-detect the disk that hosts your /hana/data directory. However, if you specify these arguments, then they override the agent's auto-detection.

    -source-disk-key-file Optional. If the disk hosting the /hana/data volume is encrypted by an RSA-wrapped customer-supplied encryption key, then specify the absolute path to that key's JSON file.

    This argument is supported from version 3.2 of the agent.

    -storage-location Optional. Specify the Cloud Storage multi-region or Cloud Storage region where you want to store your disk snapshot.
    -freeze-file-system

    Optional. Specifies whether or not the agent is to freeze the file system of your SAP HANA database. The default value is false.

    This argument is supported from version 3.2 of the agent.

    -send-metrics-to-monitoring Optional. Specifies whether or not the execution status of the snapshot creation is sent to Cloud Monitoring. The default value is TRUE.
    -loglevel Optional. Specify the logging level for the snapshot creation operation. The default logging level is info. The available log levels are: debug, info, warn, and error.
    -confirm-data-snapshot-after-create

    Optional. If you want to confirm the snapshot creation to SAP HANA immediately after the snapshot is created but without confirming that it has been uploaded to the Cloud Storage bucket specified for the -storage-location argument, then specify the value TRUE.

    The default value is FALSE, which causes the agent to confirm snapshot creation after the completion of both CREATE and UPLOAD operations.

    This argument is supported from version 3.4 of the agent.

Verify the disk snapshots

You can verify that the disk snapshots are created by using the following options:

  • In the Google Cloud console, go to the Compute Engine Snapshots page, and then filter the entries by using the disk name. If your /hana/data volume is hosted on one disk, then you can also filter by using the snapshot name. If your /hana/data volume is hosted on more than one disk, then you can also filter by using the snapshot group's name.

    Go to Snapshots

  • Alternatively, you can view the disk snapshot details in the following log file of the agent:

    /var/log/google-cloud-sap-agent/hanadiskbackup.log

Review the SAP HANA backup catalog

In addition to creating the disk snapshot based backup, the hanadiskbackup command creates an entry for it in your SAP HANA backup catalog. The following is an example SQL query to view the snapshot based backup entries in your SAP HANA backup catalog:

SELECT BACKUP_ID, STATE_NAME, COMMENT FROM M_BACKUP_CATALOG WHERE ENTRY_TYPE_NAME = 'data snapshot'

The output is similar to the following example:

BACKUP_ID,STATE_NAME,COMMENT
BACKUP_ID,"successful","SNAPSHOT_IDENTIFIER"

This output includes the following values:

  • BACKUP_ID: the backup ID assigned to the disk snapshot based backup in your SAP HANA backup catalog
  • SNAPSHOT_IDENTIFIER:
    • For a /hana/data volume on one disk, the value of this identifier is determined by the usage of the -snapshot-name argument with the hanadiskbackup command. If you didn't specify this argument, then the argument's default value is set, which is: snapshot-SOURCE_DISK_NAME-YYYYMMDD-HHMMSS.
    • If your /hana/ volume is hosted on more than one disk, then the value of this identifier is determined by the usage of the -group-snapshot-name argument with the hanadiskbackup command. If you didn't specify this argument, then the argument's default value is set, which is CONSISTENCY_GROUP_NAME-YYYYMMDD-HHMMMSS.
  • SOURCE_DISK_NAME: this value is determined by the usage of the -source-disk argument with the hanadiskbackup command.
  • CONSISTENCY_GROUP_NAME: this value is determined by the usage of the -group-snapshot-name argument with the hanadiskbackup command
  • YYYYMMDD-HHMMMSS: the date and time when the snapshot was created.

Recover the database by using a disk snapshot based backup

To recover your SAP HANA database by using the disk snapshot feature of Google Cloud's Agent for SAP, see the instructions for your scenario:

Recover the database for a scale-up system

To recover the database for an SAP HANA scale-up system deployed on Google Cloud, complete the following steps:

  1. Recover the disk hosting the /hana/data volume by running the agent's hanadiskrestore command:

    • If your /hana/data volume is hosted on one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -source-snapshot=SOURCE_SNAPSHOT_NAME \
      [-new-disk-type=NEW_DISK_TYPE \
      -new-disk-name=NEW_DISK_NAME]
    • If your /hana/data volume is hosted on more than one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -group-snapshot-name=SOURCE_SNAPSHOT_GROUP_NAME \
      [-new-disk-type=NEW_DISK_TYPE ]

    Replace the following:

    • SOURCE_PROJECT_ID: the ID of the Google Cloud project in which the disk snapshot exists
    • SID: the SAP system identifier (SID) of your SAP HANA system
    • SOURCE_SNAPSHOT_NAME: if your /hana/data volume is hosted on one disk, then specify the name of the disk snapshot using which you're creating the new disk
    • SOURCE_SNAPSHOT_GROUP_NAME: if your /hana/data volume is hosted on more than one disk, then specify the snapshot group name using which you're creating the new disks
    • NEW_DISK_TYPE: the type of disk that you want to create. For more information, see the description of -new-disk-type in Supported arguments for disk restoration.
    • NEW_DISK_NAME: the name that you want to set for the new disk. For more information, see the description of -new-disk-name in Supported arguments for disk restoration.

    For information about the arguments that you can use with the hanadiskrestore command, see Supported arguments for disk restoration.

  2. Recover your SAP HANA database using the required option:

    Recover to snapshot time

    To recover you SAP HANA database by restoring it to the time the disk snapshot was created, follow these steps:

    1. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    2. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
    3. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    4. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATA FOR TENANT_SID USING SNAPSHOT CLEAR LOG

      Replace TENANT_SID with the SID of the tenant database.

    Recover to a specific point in time

    To recover you SAP HANA database by restoring it to a specific point in time, follow these steps:

    1. Verify that you have created a backup for the /hana/log volume in Cloud Storage by using the Backint feature of Google Cloud's Agent for SAP. For more information about this feature, see Backup and recovery for SAP HANA by using Backint.
    2. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    3. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command "RECOVER DATABASE UNTIL TIMESTAMP 'YYYY-MM-DD HH:MM:SS' CLEAR LOG USING SNAPSHOT"
    4. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    5. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATABASE FOR TENANT_SID UNTIL TIMESTAMP '2099-12-31 12:00:00' CLEAR LOG USING SNAPSHOT

      Replace TENANT_SID with the SID of the tenant database.

Supported arguments for disk restoration

The following table describes the arguments supported by the agent's hanadiskrestore command:

Argument Description
-sid Specify the SAP system identifier (SID) of your SAP HANA system.
-data-disk-name Optional. Specify the name of the source disk that hosts the /hana/data volume.

From version 3.4, the arguments -data-disk-name and -data-disk-zone are optional for use with the hanadiskrestore command. This is because the agent can auto-detect the disk that hosts your /hana/data directory. However, if you specify these arguments, then they override the agent's auto-detection.

-data-disk-zone Optional. Specify the zone where the source disk that hosts the /hana/data volume, is deployed.

From version 3.4, the arguments -data-disk-name and -data-disk-zone are optional for use with the hanadiskrestore command. This is because the agent can auto-detect the disk that hosts your /hana/data directory. However, if you specify these arguments, then they override the agent's auto-detection.

-source-snapshot If your /hana/data volume is hosted on one disk, then specify the name of the disk snapshot using which you want to perform recovery.
-new-disk-name Specify the name that you want to set for the new disk. This argument is not applicable if your /hana/data volume is hosted on more than one disk.
-group-snapshot-name

If your /hana/data volume is hosted on more than one disk, then specify the snapshot group name using which you want to perform recovery.

This argument is supported from version 3.6 of the agent.

-project Optional. Specify the ID of the Google Cloud project in which the source disk snapshot exists. By default, the snapshot is created in the Google Cloud project where your SAP HANA system is running.
-csek-key-file Optional. If you encrypted the source disk snapshot by using the -source-disk-key-file argument with the hanadiskbackup command, then specify the absolute path to the JSON file of the RSA-wrapped customer-supplied encryption key that corresponds to the source disk snapshot. The following is an example key file:
[
  {
    "uri": "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots/SNAPSHOT_NAME",
    "key": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFHz0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoDD6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oeQ5lAbtt7bYAAHf5l+gJWw3sUfs0/Glw5fpdjT8Uggrr+RMZezGrltJEF293rvTIjWOEB3z5OHyHwQkvdrPDFcTqsLfh+8Hr8g+mf+7zVPEC8nEbqpdl3GPv3A7AwpFp7MA==",
    "key-type": "rsa-encrypted"
  }
]

This argument is supported from version 3.2 of the agent.

-new-disk-type

Optional. Specify the type of Persistent Disk or Hyperdisk that you want to create. By default, the new disks are of the same type of as the source disks.

Make sure that you specify an SSD-based disk type that is certified by SAP for use with SAP HANA. For more information, see Supported disk types.

-hana-sidadm Optional. Specify the SIDadm - the operating system user of your SAP HANA system.
-force-stop-hana Optional. If you want to forcefully stop SAP HANA before the initiating the recovery operation, then specify this argument and set its value to true. The default value is false.
-provisioned-iops Optional. If you're creating a Hyperdisk volume, then specify the IOPS (input/output operations per second) that it must handle.
-provisioned-throughput Optional. If you're creating a Hyperdisk volume, then specify the throughput it must support.
-labels-on-detached-disk

Optional. If you're creating a new disk to host the recovered /hana/data directory, then use this argument to specify label-value pairs that you want to associate with the detached disk. Use a comma to separate the labels. For example: -labels-on-detached-disk="label1=value1,label2=value2".

This argument is supported from version 3.4 of the agent.

-send-metrics-to-monitoring

Optional. Specifies whether or not the duration of the snapshot restore is sent to Cloud Monitoring. The default value is TRUE.

This argument is supported from version 3.4 of the agent.

-disk-size-gb

Optional. Specify the size, in GB, for the new disk. By default, the new disk is of the same size as the existing disk.

The new disk must not be smaller in size than the existing disk.

-loglevel Optional. Specify the logging level for all the actions performed by the hanadiskrestore command. The default logging level is info. The available log levels are: debug, info, warn, and error.

Recover the database for a scale-up HA system

To recover the database for an SAP HANA scale-up system deployed in a high-availability (HA) cluster on Google Cloud, complete the following steps:

  1. Verify that you have a snapshot of the disk hosting the /hana/data volume in your primary SAP HANA node.

  2. As the root user, put the HA cluster in maintenance mode. If you're using Pacemaker, then run the following command:

    RHEL

    pcs property set maintenance-mode=true

    SLES

    crm configure property maintenance-mode=true
  3. Stop your SAP HANA database instances by running the following command on both the primary and standby nodes of your HA cluster:

    HDB stop
  4. Switch to the primary node of your SAP HANA HA system.

  5. Recover the disk hosting the /hana/data volume by running the agent's hanadiskrestore command:

    • If your /hana/data volume is hosted on one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -source-snapshot=SOURCE_SNAPSHOT_NAME \
      [-new-disk-type=NEW_DISK_TYPE \
      -new-disk-name=NEW_DISK_NAME]
    • If your /hana/data volume is hosted on more than one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -group-snapshot-name=SOURCE_SNAPSHOT_GROUP_NAME \
      [-new-disk-type=NEW_DISK_TYPE ]

    Replace the following:

    • SOURCE_PROJECT_ID: the ID of the Google Cloud project in which the disk snapshot exists
    • SID: the SAP system identifier (SID) of your SAP HANA system
    • SOURCE_SNAPSHOT_NAME: if your /hana/data volume is hosted on one disk, then specify the name of the disk snapshot using which you're creating the new disk
    • SOURCE_SNAPSHOT_GROUP_NAME: if your /hana/data volume is hosted on more than one disk, then specify the snapshot group name using which you're creating the new disks
    • NEW_DISK_TYPE: the type of disk that you want to create. For more information, see the description of -new-disk-type in Supported arguments for disk restoration.
    • NEW_DISK_NAME: the name that you want to set for the new disk. For more information, see the description of -new-disk-name in Supported arguments for disk restoration.

    For information about the arguments that you can use with the hanadiskrestore command, see Supported arguments for disk restoration.

  6. Unregister the secondary node of your SAP HANA HA system:

    hdbnsutil -sr_unregister
  7. On the primary node of your SAP HANA HA system, disable the SAP HANA system replication:

    hdbnsutil -sr_disable
  8. On the primary node, recover your SAP HANA database using the required option:

    Recover to snapshot time

    To recover you SAP HANA database by restoring it to the time the disk snapshot was created, follow these steps:

    1. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    2. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
    3. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    4. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATA FOR TENANT_SID USING SNAPSHOT CLEAR LOG

      Replace TENANT_SID with the SID of the tenant database.

    Recover to a specific point in time

    To recover you SAP HANA database by restoring it to a specific point in time, follow these steps:

    1. Verify that you have created a backup for the /hana/log volume in Cloud Storage by using the Backint feature of Google Cloud's Agent for SAP. For more information about this feature, see Backup and recovery for SAP HANA by using Backint.
    2. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    3. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command "RECOVER DATABASE UNTIL TIMESTAMP 'YYYY-MM-DD HH:MM:SS' CLEAR LOG USING SNAPSHOT"
    4. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    5. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATABASE FOR TENANT_SID UNTIL TIMESTAMP '2099-12-31 12:00:00' CLEAR LOG USING SNAPSHOT

      Replace TENANT_SID with the SID of the tenant database.

  9. On the primary node, enable the SAP HANA system replication:

    hdbnsutil -sr_enable --name=PRIMARY_SITE_NAME
  10. Re-register the standby node with the primary node:

    hdbnsutil -sr_register
       --name=SECONDARY_SITE_NAME
       --remoteHost=PRIMARY_HOST_NAME
       --remoteInstance=INSTANCE_NUMBER
       --replicationMode=sync
       --operationMode=logreplay
  11. Verify that database in the standby node is fully synchronized with the database in the primary node.

  12. As the root user, exit the HA cluster maintenance mode. If you're using Pacemaker, then run the following command:

    RHEL

    pcs property set maintenance-mode=false

    SLES

    crm configure property maintenance-mode=false

Recover the database for a scale-up DR deployment

To recover the database for an SAP HANA scale-up system that is deployed with a disaster recovery solution on Google Cloud, complete the following steps:

  1. Stop your SAP HANA databases by running the following command on both the primary and standby instances of your DR deployment:

    HDB stop
  2. Switch to the primary instance of your SAP HANA DR deployment.

  3. Recover the disk hosting the /hana/data volume by running the agent's hanadiskrestore command:

    • If your /hana/data volume is hosted on one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -source-snapshot=SOURCE_SNAPSHOT_NAME \
      [-new-disk-type=NEW_DISK_TYPE \
      -new-disk-name=NEW_DISK_NAME]
    • If your /hana/data volume is hosted on more than one disk, then run the following command:

      sudo /usr/bin/google_cloud_sap_agent hanadiskrestore \
      -project=SOURCE_PROJECT_ID \
      -sid=SID \
      -group-snapshot-name=SOURCE_SNAPSHOT_GROUP_NAME \
      [-new-disk-type=NEW_DISK_TYPE ]

    Replace the following:

    • SOURCE_PROJECT_ID: the ID of the Google Cloud project in which the disk snapshot exists
    • SID: the SAP system identifier (SID) of your SAP HANA system
    • SOURCE_SNAPSHOT_NAME: if your /hana/data volume is hosted on one disk, then specify the name of the disk snapshot using which you're creating the new disk
    • SOURCE_SNAPSHOT_GROUP_NAME: if your /hana/data volume is hosted on more than one disk, then specify the snapshot group name using which you're creating the new disks
    • NEW_DISK_TYPE: the type of disk that you want to create. For more information, see the description of -new-disk-type in Supported arguments for disk restoration.
    • NEW_DISK_NAME: the name that you want to set for the new disk. For more information, see the description of -new-disk-name in Supported arguments for disk restoration.

    For information about the arguments that you can use with the hanadiskrestore command, see Supported arguments for disk restoration.

  4. On the primary instance, disable the SAP HANA system replication:

    hdbnsutil -sr_disable
  5. On the primary instance, recover your SAP HANA database using the required option:

    Recover to snapshot time

    To recover you SAP HANA database by restoring it to the time the disk snapshot was created, follow these steps:

    1. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    2. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
    3. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    4. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATA FOR TENANT_SID USING SNAPSHOT CLEAR LOG

      Replace TENANT_SID with the SID of the tenant database.

    Recover to a specific point in time

    To recover you SAP HANA database by restoring it to a specific point in time, follow these steps:

    1. Verify that you have created a backup for the /hana/log volume in Cloud Storage by using the Backint feature of Google Cloud's Agent for SAP. For more information about this feature, see Backup and recovery for SAP HANA by using Backint.
    2. Switch to the SIDadm user:
      su - SID_LCadm

      Replace SID_LC with the SID of your SAP HANA system. Use lowercase for any letters.

    3. Recover the system database by running the following command:
      HDBSettings.sh recoverSys.py --command "RECOVER DATABASE UNTIL TIMESTAMP 'YYYY-MM-DD HH:MM:SS' CLEAR LOG USING SNAPSHOT"
    4. Connect to the system database. For example, you can run the following command:
      hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

      Replace the following:

      • SYSTEM_DB_PASSWORD: your system database password
      • INSTANCE_NUMBER: your SAP HANA instance number
    5. Recover the tenant databases by running the following command for each tenant database:
      RECOVER DATABASE FOR TENANT_SID UNTIL TIMESTAMP '2099-12-31 12:00:00' CLEAR LOG USING SNAPSHOT

      Replace TENANT_SID with the SID of the tenant database.

  6. On the primary instance, enable the SAP HANA system replication:

    hdbnsutil -sr_enable --name=PRIMARY_SITE_NAME
  7. Register the standby instance with the primary instance:

    hdbnsutil -sr_register
       --name=SECONDARY_SITE_NAME
       --remoteHost=PRIMARY_HOST_NAME
       --remoteInstance=INSTANCE_NUMBER
       --replicationMode=sync
       --operationMode=logreplay
  8. Verify that database in the standby instance is fully synchronized with the database in the primary instance.

Perform a system copy or system refresh

To use a disk snapshot based backup of an SAP HANA system for recovering another SAP HANA system, complete the following steps:

  1. In the source system, create a snapshot based backup by running the agent's hanadiskbackup command. For instructions, see Create a disk snapshot based backup.
  2. If the SIDs of the source and target systems are different, then rename the /hana/data/SID directory in the source system so that it matches the target system:

    mv /hana/data/SOURCE_SID /hana/data/TARGET_SID

    Replace the following:

    • SOURCE_SID: the SID of the source SAP HANA system
    • TARGET_SID: the SID of the target SAP HANA system
  3. In the target system, recover the disk hosting the /hana/data volume by running the agent's hanadiskrestore command.

  4. In the target system, recover the system database:

    HDBSettings.sh recoverSys.py --command "RECOVER DATABASE UNTIL TIMESTAMP '2099-12-31 12:00:00' CLEAR LOG USING SOURCE 'SYSTEMDB@SOURCE_SID' USING CATALOG BACKINT USING SNAPSHOT"
  5. If you want your tenant database to have the source system's SID, then you can rename it by following the instructions in the SAP HANA document Rename a Tenant Database.

  6. In the target system, connect to the system database. For example, you can run the following command:

    hdbsql -d SYSTEMDB -u system -p "SYSTEM_DB_PASSWORD" -i INSTANCE_NUMBER

    Replace the following:

    • SYSTEM_DB_PASSWORD: your system database password
    • INSTANCE_NUMBER: your SAP HANA instance number
  7. In the target system, recover the tenant databases by running the following command for each tenant database:

    RECOVER DATABASE FOR TARGET_SID UNTIL TIMESTAMP '2023-12-08 23:59:00' CLEAR LOG USING SOURCE 'TARGET_SID@SOURCE_SID' USING CATALOG BACKINT USING SNAPSHOT

Validate snapshot consistency

This section describes how you can validate the consistency of the data in your disk snapshots by using the hdbpersdiag tool from SAP. For information about other best practices recommended by Google Cloud for disk snapshot based backup and recovery operations, see Best practices.

To validate the consistency of a snapshot, complete the following steps:

  1. Create a disk from a snapshot that you created by using the agent's hanadiskbackup command. Use the gcloud compute disks create command:

    gcloud compute disks create DISK_NAME \
       --size=SIZE \
       --source-snapshot=SNAPSHOT_NAME \
       --type=DISK_TYPE \
       --zone=ZONE
    

    Replace the following:

    • DISK_NAME: the name of the temporary disk
    • SIZE: the size of the temporary disk
    • SNAPSHOT_NAME: the name of the source snapshot
    • DISK_TYPE: the disk type for the temporary disk
    • ZONE: the Compute Engine zone where you want to deploy the temporary disk
  2. Attach the disk to a VM other than your SAP HANA host. Use the gcloud compute instances attach-disk command:

    gcloud compute instances attach-disk VM_INSTANCE_NAME \
       --disk=DISK_NAME \
       --zone=ZONE
    

    Replace the following:

    • VM_INSTANCE_NAME: the name of the VM where you want to deploy the disk you created
    • DISK_NAME: the name of the disk you created
    • ZONE: the Compute Engine zone where your VM is deployed
  3. Connect to your VM using your preferred SSH method.

  4. Mount the new disk as a temporary file system:

    1. At the OS level, find the volume group that doesn't have any active logical volume:

      vgdisplay
      

      The output is similar to the following example:

      --- Volume group ---
      VG Name               vg_hana_data
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  2
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               0
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               250.00 GiB
      PE Size               4.00 MiB
      Total PE              63999
      Alloc PE / Size       63999 / 250.00 GiB
      Free  PE / Size       0 / 0
      VG UUID               Fa52zl-AROR-LH2k-aG4z-LbrB-cvTz-TZhEfR
    2. Rename the volume group using the VG UUID. In the preceding example it's Fa52zl-AROR-LH2k-aG4z-LbrB-cvTz-TZhEfR.

      vgrename Fa52zl-AROR-LH2k-aG4z-LbrB-cvTz-TZhEfR vg_hana_data_temp
      
    3. Activate the volume group and the logical volume:

      vgchange -a y vg_hana_data_temp
      lvchange -a y /dev/vg_hana_data_temp/data
      
    4. Mount the logical volume in a temporary file system, for example, /hana/data_temp:

      mkdir /hana/data_temp
      mount /dev/vg_hana_data_temp/data /hana/data_temp
      
    5. Verify that all the disks are properly mounted:

      lsblk
      

      The output is similar to the following example:

      NAME                     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
      sda                        8:0    0   30G  0 disk
      ├─sda1                     8:1    0    2M  0 part
      ├─sda2                     8:2    0   20M  0 part /boot/efi
      └─sda3                     8:3    0   30G  0 part /
      sdb                        8:16   0  350G  0 disk
      └─vg_hana_data_temp-data 254:5    0  250G  0 lvm  /hana/data_temp
      sdc                        8:32   0  104G  0 disk
      └─vg_hana_log-log        254:2    0  104G  0 lvm  /hana/log
      sdd                        8:48   0  208G  0 disk
      └─vg_hana_shared-shared  254:0    0  208G  0 lvm  /hana/shared
      sde                        8:64   0   32G  0 disk
      └─vg_hana_usrsap-usrsap  254:3    0   32G  0 lvm  /usr/sap
      sdf                        8:80   0  416G  0 disk
      └─vg_hanabackup-backup   254:4    0  416G  0 lvm  /hanabackup
      sdh                        8:112  0  250G  0 disk
      └─vg_hana_data-data      254:1    0  250G  0 lvm  /hana/data
  5. As the SIDadm user, run the hdbpersdiag tool for the data volumes that are included in the temporary file system:

    for directory in $(find /hana/data_temp/SID/mnt00001/hdb* -type d); do hdbpersdiag -c -e 'check all' $directory; done
    
  6. Verify the output from the hdbpersdiag tool.

  7. If you plan on performing this consistency check in the future, then you can leave the new volume group as it is. If not, then delete it.

  8. Detach the disk from the VM. Use the gcloud compute instances detach-disk command:

    VM_INSTANCE_NAME \
       --disk=DISK_NAME \
       --zone=ZONE
    
  9. Delete the disk. Use the gcloud compute disks delete command:

    gcloud compute disks delete DISK_NAME \
       --zone=ZONE
    

Troubleshooting

While Google Cloud's Agent for SAP is designed to take care of most issues that can occur during disk snapshot based backup and recovery operations for SAP HANA, there are a few scenarios where manual intervention is required.

To troubleshoot any issue with the disk snapshot feature of Google Cloud's Agent for SAP, see Issue with a disk snapshot based backup or recovery operation.

Get support

If you need help resolving a problem with Google Cloud's Agent for SAP, then gather the required diagnostic information and contact Cloud Customer Care. For more information, see Google Cloud's Agent for SAP for SAP HANA diagnostic information.