Skip to Content
Previous

Create a Backup

By Adrian Plata

Learn how to complete common tasks when setting up a new database. In this tutorial, you will create a backup for your database using HANA cockpit, HANA studio, or SQL.

You will learn

How to create a backup for you database using either HANA Cockpit, HANA Studio, or a SQL command line.

Details


Option 1: SAP HANA Cockpit

Note:
This option requires an SAP HANA, express edition Server + Applications installation.

  1. Open SAP HANA Cockpit and log in using XSA_ADMIN.

  2. Open your system database in the Resource Directory window.

  3. Scroll down to the System DB Monitoring and Administration section and click Manage database backups under Administration.

    Manage Database Backups
  4. On the bottom right of the page, click Create Backup.

    Create Your Backup
  5. Select your Backup Type and Destination Type. You may also change the Backup Prefix and Backup Destination. By default the values for Backup Prefix and Backup Destination are <date>_<time> and /usr/sap/<sid>/HDB90/backup/data/SYSTEMDB/.

    Click Back Up to create your backup.

    Create Backup
  6. A new page will open with a progress bar. Creating your backup will take a few minutes.

  7. Once the backup is complete, a new page will show your successful backup. Two files are created: <backup_prefix>_databackup_0_1 and <backup_prefix>_databackup_1_1.

    Successful Backup
Option 2: SAP HANA Studio

Note:
This option requires you to have completed the How to download and install the HANA Eclipse plugin How-To.

  1. On SAP HANA Studio, log on to your SAP HANA, express edition installation.

  2. Double-click the Backup icon Backup.

  3. If this is your first backup, under the Overview tab, click back up now. If this is not your first backup, click the Open Backup Wizard icon Backup by Status of Currently Active Data Backup.

    SAP HANA Studio Backup

    The backup window opens.

  4. Choose your Backup Type and Destination Type as necessary. By default, the values are Complete Data Backup and File.

    • Choose your Backup Destination and Backup Prefix. This will be where your files are stored and what they will be called. By default, the values are /usr/sap/<sid>/HDB<instance_number>/backup/data/SYSTEMDB and COMPLETE_DATA_BACKUP.

    • When you are finished, click Next >.

    Backup Window
  5. Review your backup settings and click Finish to begin creating your backup. Creating your backup will take a few minutes.

Option 3: SQL and Command Line
  1. In SAP HANA Studio or another connected SQL command line, create a backup user and grant it backup permissions.

    CREATE USER backup_operator PASSWORD <password> NO FORCE_FIRST_PASSWORD_CHANGE;
    GRANT BACKUP OPERATOR to backup_operator;
    ALTER USER backup_operator DISABLE PASSWORD LIFETIME;
    

    This creates the user backup_operator with the given password and tells the system to not require a password change upon first login. It gives also gives backup_operator permission to make backups. You will be using this user to only create backups so logging in for each backup is not required. You only need to do this once.

  2. Connect to your SAP HANA, express edition installation using a command line.

  3. Log in as hxeadm.

    su -l hxeadm
    
  4. Create the backup key.

    Execute the following command to create the user key backup.

    hdbuserstore -i SET backup <hostname>:3<instance_number>13 backup_operator
    
  5. Create the file backup.sh.

    vi backup.sh
    

    Copy and paste the following code:

    ## defines backup prefix
    TIMESTAMP="$(date +\%F\_%H\%M)"
    BACKUP_PREFIX="SCHEDULED"
    BACKUP_PREFIX="$BACKUP_PREFIX"_"$TIMESTAMP"
    # TENANT="<tenant_database_name>"
    ## runs the backup sequence using the backup key
    hdbsql -U backup "backup data using file ('$BACKUP_PREFIX')"
    # hdbsql -U backup "backup data for $TENANT using file ('$BACKUP_PREFIX')"
    

    This script will be used to create your backups. If you need to backup more than one database (you have tenant databases, for example), use the commented sections as a template.

  6. Give backup.sh run permission.

    chmod u+x backup.sh
    
  7. Run backup.sh.

    <location_of_backup_script>/backup.sh
    

    Example:

    /hana/shared/HXE/HDB90/backup.sh
    

    Wait while your backup is created.

  8. (Optional) Check your backup repository to ensure your backup was created.

    ls /usr/sap/<sid>/HDB<instance_number>/backup/data/SYSTEMDB
    

    Example:

    ls /usr/sap/HXE/HDB90/backup/data/SYSTEMDB
    

    A list of your backup files is displayed.

Next Steps

Updated 09/13/2017

Time to Complete

15 Min

Beginner

Tags

Prerequisites

Next Steps

Next
Back to top