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
- Validate the installation of Google Cloud's Agent for SAP. For instructions, see Install and configure Google Cloud's Agent for SAP on a Compute Engine VM instance.
Validate that your SAP HANA system is deployed on a Compute Engine VM instance as follows:
- It is not deployed in a scale-out architecture. For more information, see Using snapshots with scale-out deployments.
- It uses an SAP-certified operating system (OS). For more information, see OS support for SAP HANA on Google Cloud
- The
/hana/data
volume is independently hosted on one or more SSD-based Persistent Disk or Hyperdisk volume. These disks must host no other SAP HANA volume. As described in the SAP Note 2039883 - FAQ: SAP HANA database and data snapshots (storage snapshots), to be able to recover your SAP HANA database, the storage snapshot must not include the log area of the database.
If you're using more than one disk to host your
/hana/data
volume, then you can use the disk snapshot feature of the agent only when the underlying disks are Hyperdisk volumes.- The
/hana/data
volume is mapped to a logical volume. This enables the agent correctly handle the mount point during disk snapshot based backup or recovery operations. - The underlying infrastructure is not deployed using Infrastructure as Code (IaC) tools such as Terraform. For more information, see Using snapshots with IaC tool based deployments.
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
, andcompute.disk.list
.
- For the Google Cloud project where your SAP HANA system runs, enable
the
- 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
- If your
- To create disk snapshot based backups, the SAP HANA database user used by the
agent must have the
BACKUP OPERATOR
orBACKUP 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 havesudo
access to run the following commands. You can also providesudo
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 thehanadiskbackup
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 thehanadiskbackup
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 snapshotHANA_HOST_ADDRESS
: the hostname or IP address of the Compute Engine VM instance that hosts your SAP HANA databaseIn 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 requestsSID
: the SAP system identifier (SID) of your SAP HANA systemHANA_USERNAME
: the SAP HANA database username using which you want to create the backupHANA_USER_PWD_SECRET_NAME
: if you're using Secret Manager to store the SAP HANA database user's password, then specify the corresponding secret nameHDB_USERSTORE_KEY
: if you've created anhdbuserstore
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
andhdbuserstore
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. HereSID
refers to the value that you've specified for thesid
parameter. You can verify this by running the following command as theSIDadm
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 thehanadiskbackup
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 thehanadiskbackup
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
, anderror
.-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 valueTRUE
.The default value is
FALSE
, which causes the agent to confirm snapshot creation after the completion of bothCREATE
andUPLOAD
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.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 catalogSNAPSHOT_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 thehanadiskbackup
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 thehanadiskbackup
command. If you didn't specify this argument, then the argument's default value is set, which isCONSISTENCY_GROUP_NAME-YYYYMMDD-HHMMMSS
.
- For a
SOURCE_DISK_NAME
: this value is determined by the usage of the-source-disk
argument with thehanadiskbackup
command.CONSISTENCY_GROUP_NAME
: this value is determined by the usage of the-group-snapshot-name
argument with thehanadiskbackup
commandYYYYMMDD-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
- Recover the database for a scale-up HA system
- Recover the database for a scale-up DR deployment
- Perform a system copy or system refresh
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:
Recover the disk hosting the
/hana/data
volume by running the agent'shanadiskrestore
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 existsSID
: the SAP system identifier (SID) of your SAP HANA systemSOURCE_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 diskSOURCE_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 disksNEW_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.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:
- Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - Recover the system database by running the following command:
HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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:
- 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. - Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - 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"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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.
- Switch to the
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-zone |
Optional. Specify the
zone where the
source disk that hosts the /hana/data volume, is deployed.
From version 3.4, the arguments
|
-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 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
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
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:
Verify that you have a snapshot of the disk hosting the
/hana/data
volume in your primary SAP HANA node.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
Stop your SAP HANA database instances by running the following command on both the primary and standby nodes of your HA cluster:
HDB stop
Switch to the primary node of your SAP HANA HA system.
Recover the disk hosting the
/hana/data
volume by running the agent'shanadiskrestore
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 existsSID
: the SAP system identifier (SID) of your SAP HANA systemSOURCE_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 diskSOURCE_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 disksNEW_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.Unregister the secondary node of your SAP HANA HA system:
hdbnsutil -sr_unregister
On the primary node of your SAP HANA HA system, disable the SAP HANA system replication:
hdbnsutil -sr_disable
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:
- Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - Recover the system database by running the following command:
HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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:
- 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. - Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - 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"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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.
- Switch to the
On the primary node, enable the SAP HANA system replication:
hdbnsutil -sr_enable --name=PRIMARY_SITE_NAME
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
Verify that database in the standby node is fully synchronized with the database in the primary node.
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:
Stop your SAP HANA databases by running the following command on both the primary and standby instances of your DR deployment:
HDB stop
Switch to the primary instance of your SAP HANA DR deployment.
Recover the disk hosting the
/hana/data
volume by running the agent'shanadiskrestore
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 existsSID
: the SAP system identifier (SID) of your SAP HANA systemSOURCE_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 diskSOURCE_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 disksNEW_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.On the primary instance, disable the SAP HANA system replication:
hdbnsutil -sr_disable
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:
- Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - Recover the system database by running the following command:
HDBSettings.sh recoverSys.py --command="RECOVER DATA USING SNAPSHOT CLEAR LOG;"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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:
- 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. - Switch to the
SIDadm
user:su - SID_LCadm
Replace
SID_LC
with the SID of your SAP HANA system. Use lowercase for any letters. - 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"
- 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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
- 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.
- Switch to the
On the primary instance, enable the SAP HANA system replication:
hdbnsutil -sr_enable --name=PRIMARY_SITE_NAME
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
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:
- 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. 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 systemTARGET_SID
: the SID of the target SAP HANA system
In the target system, recover the disk hosting the
/hana/data
volume by running the agent'shanadiskrestore
command.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"
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.
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 passwordINSTANCE_NUMBER
: your SAP HANA instance number
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:
Create a disk from a snapshot that you created by using the agent's
hanadiskbackup
command. Use thegcloud 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 diskSIZE
: the size of the temporary diskSNAPSHOT_NAME
: the name of the source snapshotDISK_TYPE
: the disk type for the temporary diskZONE
: the Compute Engine zone where you want to deploy the temporary disk
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 createdDISK_NAME
: the name of the disk you createdZONE
: the Compute Engine zone where your VM is deployed
Connect to your VM using your preferred SSH method.
Mount the new disk as a temporary file system:
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
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
Activate the volume group and the logical volume:
vgchange -a y vg_hana_data_temp lvchange -a y /dev/vg_hana_data_temp/data
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
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
As the
SIDadm
user, run thehdbpersdiag
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
Verify the output from the
hdbpersdiag
tool.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.
Detach the disk from the VM. Use the
gcloud compute instances detach-disk
command:VM_INSTANCE_NAME \ --disk=DISK_NAME \ --zone=ZONE
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.