Search code examples
hanadatabase-backups

How to take backup by schema wise in SAP HANA


I am performing a backup in HANA using

hdbsql HDB=> BACKUP DATA USING FILE ('/backup/HDB/data/BACKUP_FULL_20170514/SAPHANA')

Instead of this I would like to have a backup by schema wise and make it as a cronjob. How to take backup by schema wise in SAP HANA?


Solution

  • Ok, this is a common question, not just for HANA but for any DBMS with schema support.
    The short answer is: it's not possible to backup/restore data based on schemas. A schema is a namespace in the database, while backup/restore are functions of the data persistence.

    As transactions can span multiple schemas, restoring just a single schema might lead to inconsistencies, as transactions would only be partly recovered.

    Having said all that, typically the actual requirement is not to backup/restore separate schemas, but to allow for the handling of multiple database tenants on a shared system.

    SAP HANA supports this with Multi-Database-Containers. Each tenant gets its own set of database processes, memory, filesystems, etc. but the HANA software installation is shared.

    That way it's easy to backup/recover a single tenant without affecting the other tenants. Another benefit with this approach is that the schema itself will have the same name in all tenant DBs, making maintenance easier.