SAP HANA makes use of persistence device to recover from system crash. Last article mentioned that undo log, redo log and save-point can be used to prevent from crash such as power-off automatically. But if the persistence devices (such as disk) break down, that mechanism cannot be reliable. To prevent hardware from damage, database administrator needs to back up the database.
The difference between recovery from restart and recovery from back up is that system recovery from back-up by using external devices. There are 2 parts of back up database: log back-up and data back-up. They are independent with each other. The process of backup has negligible influence to performance of SAP HANA database. There are 5 points you need to remember.
- Back up of SAP HANA need authorizations as below.
Authorization name | Comment |
BACKUP ADMIN | Authorization of back up execution |
CATALOG READ | Authorization of collecting information |
- SAP HANA won’t process log backup until first data backup finished.
- Backup and recovery always apply to the whole database. It is not possible to back up and recover individual.
- SAP HANA database can be backed up to the file system or using third-part backup tools.
- Shared storage is strongly recommended, as it makes the data area available to all the nodes in a database.
Log backup
The system can perform regular automatic backups of the redo logs. During a log backup, the payload of the log segments is copied from the log area to service-specific log backups or to a third-party backup server.A log segment is backed up in the following situations:
- The log segment is full.
- The log segment is closed after exceeding the configured time threshold.
- The database is started.
System administrator can set the mode of backup as below.There are two kinds of log mode:
1. Normal(default)
Log segments are automatically backed up if parameter enable_auto_log_backup is enabled. Log mode normal is recommended to provide support for point-in-time recovery. Automatic log backups can prevent log-full situations from arising.
2. Overwrite
Log segments are freed by savepoints and no log backups are performed. This can be useful, for example, for test installations that do not need to be backed up or recovered.System user also can set the interval of log backup. The default interval is 900s.If the log area damaged, the data updated in this interval will not recovered. If it is set to 0, system backup the log only when log segment is full or system restart.
Data backup
A data area backup includes all the database content: transaction data and administrative data (for example, users, roles, models, and views). Only the actual data is backed up; unused space in the database is not backed up. When a data area backup is performed, the data area is backed up for each of the SAP HANA services running. If SAP HANA is running on multiple hosts, the data backup includes all the service-specific backup parts for all the hosts.By default, data backups are written to the following destination: $DIR_INSTANCE/backup/data. You can specify a different destination when you perform the backup. Alternatively, you can change the default backup destination using the Backup editor in SAP HANA studio.There are 3 ways to perform a data backup:
- SAP HANA studio
- SQL commands
- Batch mode
Performing a Data Backup Using SAP HANA Studio
- Right click “System”, choose “Back Up…”, choose the type of backup. You can choose other type if you installed other third-party tools.
- Specify the backup destination and the backup prefix. The default destination is the path specified on the Configuration tab of the Backup editor.
- Choose Next. A summary of the backup settings is displayed.
- If all the settings are correct, choose Finish.
- The backup starts.
Performing a Data Backup Using SQL Commands
You can enter SQL commands either by using the SQL console in SAP HANA studio, or by using the command line program hdbsql.SQL command:
BACKUP DATA USING FILE ('<path><prefix>')
Example:BACKUP DATA USING FILE ('/backup/data/MONDAY/COMPLETE_DATA_BACKUP')
This would create the following files in the directory /backup/data/MONDAY:COMPLETE_DATA_BACKUP_databackup_0_1 (name server topology)
COMPLETE_DATA_BACKUP_databackup_1_1 (name server)COMPLETE_DATA_BACKUP_databackup_2_1 (for example, index server)...
Performing a Data Backup in Batch Mode
You can perform data backups in batch mode at operating system level using the command line tool SAP HANA HDBSQL. HDBSQL enables you to trigger backups through crontab. It is recommended that you set up a batch user for this purpose and that you authorize this user to perform backups with the system privilege BACKUP OPERATOR.Procedure:
1. Install the client software by executing the following command:
hdbinst –a client (default location: /usr/sap/hdbclient).The client software enables access to hdbuserstore.
2. Create a user key by executing the following command:
/usr/sap/hdbclient/hdbuserstore set <KEY> <host>:3<instance id>15 <user> <password>
3. In crontab, execute the following command at the desired time:/usr/sap/hdbclient/hdbsql –U<KEY> "BACKUP DATA USING FILE ('<path><prefix>')"