SAP HANA Database auto backup to FTP server daily

There is nothing more important than securing your data. Although SAP HANA studio provides a way to auto backup your database but it is better to have those backup saved off site.

Here we provide a way to back your HANA database and save it to ftp server.

the file structure is here.

/usr/sap/NDB/HDB00/backup/autobackup/MTC       folder to save temporary backup data and log files.
/usr/sap/NDB/HDB00/backup/autobackup/MTC.sql   HANA database backup query script.
/usr/sap/NDB/HDB00/backup/autobackup/ Main script to auto backup.
/usr/sap/NDB/HDB00/backup/autobackup/    Script to upload tar files to ftp server.


EXPORT "MTC"."*" AS BINARY INTO '/usr/sap/NDB/HDB00/backup/autobackup/MTC' WITH REPLACE THREADS 10;

cd /usr/sap/NDB/HDB00/backup/autobackup
rm -fr MTC/*

echo "Starting backup MTC"
/usr/sap/NDB/HDB00/exe/hdbsql -u SYSTEM -p Password -i 00 -c ";" -I "/usr/sap/NDB/HDB00/backup/autobackup/MTC.sql"
tar cf "MTC-$(date '+%Y-%m-%d').tar.gz" MTC/
echo "Backup MTC Done"
rm -fr MTC/*
chmod 755 -R *.tar.gz

echo "Upload to FTP"   
./     run script
echo "Done"

ftp -inv $HOST <<EOF
user $USER $PASS
cd /usr/sap/NDB/HDB00/backup/autobackup
cd /Shares/Backup/HANASERVER  remote ftp folder
mput *.tar.gz

Finally create a cron job to run the daily.

crontab -e

3 22 * * * /usr/sap/NDB/HDB00/backup/autobackup/  >> /var/log/HanaDB-Backup.log 2>&1

Test: every day 9:03PM, the cron job will be run, backup the database, compress the whole backup folder, update the tar file to ftp server.

Hope this can help.

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

sixteen − 6 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.