Learning: Performing Backup and Recovery
Tags: sap, certification
Published: 2024-04-26 19:31:22

Learning notes from the learning journey: Installing and Administering SAP HANA to take the Certification "SAP Certified Associate - Database Administrator - SAP HANA".

- Describing Backup and Recovery:

The <u>SYSTEMDB and all tenants</u> are separate databases, which can be individually backed up and restored.  

** Individual database objects cannot be backed up and recovered.

RESTORING: Restoring from a higher source into a lower target released is not supported. Also, restoring a backup of a single-container system to a multi-container is done automatically recovered to a tenant database. <u>However, a single container system to SYSTEMDB is not supported.</u>
 
Backups and recovery require system privileges. 

- Performing, scheduling Data Backups:
 
TYPES OF BACKUPS: 
 1) Complete data backups: includes all the data that is required to recover the database to a consistent state.
 2) Incremental Backup: Stores the data changed since the last full data backup or the last delta backup. - Delta Backup can reduce backup time 
 3) Differential Backups: Stores the data changed since the last full data backup or the last full backup. - Delta Backup can reduce backup time 

 ** Changes remain to the physical layout of the data.

To identify the estimation of the backup, use M_BACKUP_SIZE_ESTIMATIONS, because if there is no space, the backup fails.

SCHEDULING: Cockpit -> Database Management -> BackUp schedules (they are scheduled but occur independently of the cockpit).

- Configuring Log BackUps:

Log buffer is saved into a log segment to disk (memory). Log backups (normal) are performed automatically when a log segment is full, or when a log segment becomes older **than 15 minutes**. If the log_mode is "overwrite", no point in time recovery is possible therefore only complete data backup can be used.

- Recovery of Tenant Database:

A recovery of the SYSTEMDB or tenant is needed if there is a disk crash or log area, which requests a reset to a specific point in time or creating a database copy. All of them are required to have <u>system privilege</u> and <u><sid>adm user.</u>

TYPES OF RECOVERY:
 1) Until the most recent state: recovery as close as possible to the current time. 
 2) Point in Time: Recover of a specific point in time.
 3) Specific BackUp: Recovery of a specific data backup, however, it does not support the delta backups. 

** Tenant database is only recovered if it is corrupted.

BACKUP.LOG: records information about the data and log backups, progress and recovery.
BACKINT.LOG: contains info about the activities of the backint agent.
BACKUP CATALOG: Displays a list of past backups and their information. They can be accessed through views: M_BACKUP_CATALOG, M_BACKUP_CATALOG_FILES, and M_BACKUP_PROGRESS.

LIFECYCLE MANAGEMENT: Backups are memory, so it's recommended always to check the backup generations that can be deleted. 

** By default 2 generations of backups are retained, but it's possible to choose between 1 and 14 generations of backups.

- Illustrating Advanced Backup and Recovery Techniques

DATA SNAPSHOT: captures the state of the data volume on the storage system at a point in time. It storages all the information to recover the SYSTEMDB to a consistent state (they don't consume database resources).

SYSTEMDB -> can be recovered using Cockpit, SQL Statements and Python scripts

TENANT DATABASE: cannot be recovered using the command-line tool.

- Fallback Snapshot: 

Fallback snapshot features lets you easily create a snapshot that ensures the rollback possibility without creating a complete backup. 

- Database copy scenarios:

PREREQUISITES FOR SOURCES: Copy using file-based backups or created by third-party tools.
PREREQUISITES FOR TARGET: Database target version must be the same or higher than the source database, and the target must have sufficient disk space and memory, target can have any number of hosts.