Last active
March 22, 2021 12:44
-
-
Save shaheerxt/43a3b9f12b2b74a1e87817bfe9373fae to your computer and use it in GitHub Desktop.
Prepare cron scheduled script for HANA backups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--sql commands | |
//setup user (named backupuser, for backup operations) | |
//login to SYSTEMDB-> SYSTEM user | |
create user backupuser password BackupUser1234; | |
alter user backupuser disable password lifetime; | |
grant Database backup admin,backup admin, catalog read to backupuser; | |
alter user backupuser activate; | |
--bash terminal | |
#setup userstore key (backupuser as user for backup operations) | |
hdbuserstore set bkpuser node01:30113 backupuser BackupUser1234 | |
#for scaleout use the below method | |
hdbuserstore set bkpuser node01:30113 backupuser BackupUser1234 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--bash terminal | |
setup the script with any name,say db_backup.sh under the path anywhere, for eg: /usr/sap/ABC/HDB02 | |
#!/bin/bash | |
# define backup prefix | |
TIMESTAMP="$(date +\%F\_%H\%M)" | |
BACKUP_PREFIX="SCHEDULED" | |
BACKUP_PREFIX="$BACKUP_PREFIX"_"$TIMESTAMP" | |
# source HANA environment | |
. /usr/sap/ABC/HDB02/hdbenv.sh | |
# execute command with user key | |
# asynchronous runs job in background and returns prompt | |
hdbsql -U bkpuser "backup data using file ('$BACKUP_PREFIX') ASYNCHRONOUS" #for the sytemdb | |
hdbsql -U bkpuser "backup data for ABC using file ('$BACKUP_PREFIX') ASYNCHRONOUS" #for the tenantdb | |
--schedule in crontab, say this runs everyday at 10PM server time | |
00 22 * * * sh /usr/sap/ABC/HDB02/db_backup.sh >> /tmp/tmp1.log 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment