ITPub博客

首页 > 自动化运维 > 应用服务器 > 【BASIS】HANA备份脚本,Catalog自动清理

【BASIS】HANA备份脚本,Catalog自动清理

应用服务器 作者:penguin.23 时间:2020-12-14 18:23:18 0 删除 编辑

1、创建备份的数据库账号;

create user <Backup User Name> password "<Password>";

alter user <Backup User Name> DISABLE PASSWORD LIFETIME;

grant backup admin to <Backup User Name>;

2、加密HANA账号登陆凭据;
hdbuserstore set USER4BACKUP localhost:3<Instance Number>15 <Backup User Name> <Password>

3、自动备份脚本;

#!/bin/sh

#/* Backup script */

source $HOME/.bashrc

date="$(date +"%Y-%m-%d")"

time="$(date +"%Y-%m-%d %H:%M:%S")"

backup="backup data using file ('$date')"

echo "daily backup  :"  $time  "Start" >> $DIR_INSTANCE/backup.log

$DIR_EXECUTABLE/hdbsql -U USER4BACKUP -x $backup 

time="$(date +"%Y-%m-%d %H:%M:%S")"

echo "daily backup  :"  $time  "End" >> $DIR_INSTANCE/backup.log

time="$(date +"%Y-%m-%d %H:%M:%S")"

4、自动清理Hana Catalog脚本;

sql="select top 1 REPLACE(BACKUP_ID,',','') as A from M_BACKUP_CATALOG where ENTRY_TYPE_NAME='complete data backup' and UTC_START_TIME <= ADD_DAYS(CURRENT_UTCDATE,-7) order by UTC_END_TIME desc"

backupid=`$DIR_EXECUTABLE/hdbsql -U USER4BACKUP  -x $sql | grep \" | sed -e 's/\"//g'`


if [ -z $backupid ]

then

        echo "backupid not found"

else

        sql="BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $backupid COMPLETE"

        $DIR_EXECUTABLE/hdbsql -U USER4BACKUP -x $sql

fi

5、 第三、四两段脚本合起来,配置自动任务执行。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20659905/viewspace-2742176/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-05-12

  • 博文量
    59
  • 访问量
    148815