Configuring Log Backups

Objectives

After completing this lesson, you will be able to:

  • Configure a log area backup

Log Management

Business Example

You have to understand the SAP HANA automatic log backup mechanism, the different log modes, and need to be able to configure the log backups according to the backup and recovery strategy.

All data changes are recorded in the redo log buffer. When a database transaction is committed, the redo log buffer is saved into a log segment to disk. Also, if the redo log buffer fills at any time, the redo log buffer is written to disk anyway, even if no commit has been sent.

Multiple log buffers are normally combined into log segment. The log segment size can be configured using the parameter log_segment_size_mb. For the Index Server, the default log segment size is 1 GB.

Automatic Log Backups

You can enable or disable automatic log backup with the enable_auto_log_backup parameter. The default setting is enable_auto_log_backup = yes.

To allow the reuse of log segments, the system performs automatic log backups. During a log backup, the log segments are copied from the basepath_logbackup location to the location basepath_logbackup.

Note
Every SAP HANA service that stores data in RAM has its own transaction log mechanism with dedicated log segments and log backups.

A log segment is automatically backed up in the following situations:

  • The log segment is full.

  • The log segment is closed after exceeding the configured timeout threshold.

  • The database is started.

Log segments can only be overwritten by the system after they have been backed up. If no regular log backups take place, you risk that the file system basepath_logvolume becoming full.

Caution

Do not delete log segments from the basepath_logvolume at the operating system level, because the log area becomes unusable and the database stops working.

To avoid the location basepath_logbackup from becoming full, make sure to archive the log backups according to your backup cycle defined in your backup and recovery strategy.

Note

Backups made using third-party tools always use the destination /usr/sap/<SID>/SYS/global/hdb/backint

Log Modes

The system can reuse the space that is occupied in the log volume by the log segments. The log_mode parameter controls how the log segments are reused.

log_mode = normal

The configuration log_mode = normal means log segments are freed as soon as a log backup is performed. This is the default log mode and is required for all systems that need to able to be recovered.

With log_mode = normal a point-in-time recovery, a full recovery, and recover to a specific data backup are possible.

log_mode = normal is the default mode and support the following features:

  • Keeps log segments until back up

  • Log backups are performed automatically when a log segment is full, or when a log segment becomes older than 15 minutes. The log backup timeout can be configured using the parameter log_backup_timeout_s.

  • Log backup directory configured with parameter basepath_logbackup

  • The backup catalog is maintained.

  • Restoring from any available data backup with log replay to the last committed state.

  • Restoring any available data backup without log replay.

Log segments in the log area are only released for overwrite after a successful log backup. In some situations, there can be a delay in releasing log segments because they are waiting to be backed up. As a result of this delay, the log area can grow. If the log segments cannot be backed up and released faster than SAP HANA will automatically create a new log segment, this way the can continue to work by adding new log segments until the log volume area become full.

For productive systems, use normal log mode because it provides the highest security for the restoration of data during a recovery of the SAP HANA database. In normal log mode, the system automatically creates log backups that can be used for a recovery in addition to the data backups. However, more backup space is required in this log mode because of the log backups. Therefore, an operational concept for administrating data and log backups is a prerequisite for using normal log mode.

After changing the log mode parameters, restart the database system to activate the changes. Also, create a full data backup of the database.

Note

After installation, SAP HANA temporarily runs in overwrite log mode. After you create the first full data backup, SAP HANA automatically switches to the default normal log mode.

log_mode = overwrite

Using this configuration means log segments are freed by savepoints, and no log backups need to be performed. This log mode can be useful, for example, for test installations or training systems that do not need to be recovered.

With log_mode = overwrite, no point-in-time recovery is possible as there are no log backups created. For recovery, only a complete data backup can be used. The only option available for recovery is Recover to a specific data backup.

Caution

The overwrite mode, log_mode = overwrite, is not recommended for production systems.

Log Backup Timeout Parameter

The parameter log_backup_timeout_s in the global.ini configuration file defines the interval at which log backups are created. By default, the log backup interval is 15 minutes (900 s).

Specifying an appropriate interval for log backups enables you to recover an SAP HANA database with a good Recovery Point Objective (RPO). In the event of database failure, the RPO is the maximum time span of data that will be lost if the log area cannot be used for recovery, and if only data backups, delta backups, and log backups are available.

Note

If the log segments become full before the log backup interval, the logs are backed up automatically. A time interval of 0 means that log backups are created only when a log segment is full and when services are restarted.

Note

The log_backup_timeout_s parameter only takes effect if enable_auto_log_backup is set.

For log_mode = normal, these parameters must have the following values:

  • enable_auto_log_backup = yes

  • log_backup_timeout_s > 0

To provide full point-in-time recoverability, enable automatic log backups in production systems. An alert notifies administrators when automatic log backups are disabled.

Note

Improvements for log backups when using BACKINT include the following:

  • In some cases, third-party backup tools have encountered deadlocks when two SAP HANA database services requested log backups from the same tape (there is no concurrent access to the tape). The internal recovery handling of SAP HANA has been adapted to avoid deadlock situations when retrieving log backups from a third-party backup tool that uses tapes.

  • In some scenarios, the start of a third-party backup agent for a log backup can take longer than the actual log backup itself. During times of high load, this can cause many pending log backups and, in the worst case, log full situations (log segments are only released for overwrite after a successful log backup). SAP HANA now uses a single backup call to the third-party agent for all log segments of a service that are ready for backup.

Consolidated Log Backups

With a well-operated SAP HANA system, many log backups are created. It is common to have over 2,000 backup files per day. External backup tools can have problems with digesting so many files. SAP HANA uses several options to reduce the number of backup files that are created.

To improve the performance of log backups, SAP HANA can write all the log segments of a service that are ready to be backed up at a particular time to a single log backup. You can define the maximum size of this single log backup. This option is supported for both file-based backups and third-party tools.

Note

The option to consolidate log backups is primarily intended for use with third-party backup tools that create a large number of small backups in a short time. However, consolidated log backups are supported for both third-party backup tools and file system backups.

The parameter log_backup_interval_mode defines when a log backup should be triggered.

log_backup_interval_mode = immediate
In the mode "immediate" a log backup will be executed immediately after a log segment becomes full or no later than the service-specific timeout has been reached for a log segment.
log_backup_interval_mode = service
In the mode "service" a log backup will be executed only after a service-specific timeout has been reached. This backup will enclose all log segments in states "writing", "closed" and "truncated".

The maximum size of the log segments to be processed by a single backup operation is defined by the parameter max_log_backup_size in the backup section of the global.ini file. The default value is 16 GB.

Log in to track your progress & complete quizzes