首页 > 其他分享 >SAP HANA 自动备份

SAP HANA 自动备份

时间:2023-06-07 17:03:11浏览次数:36  
标签:prd backup HANA CATALOG key backupid SAP BACKUP 备份

1.创建db 账号 dbbackup ,授予backup admin、catalog read 系统权限

CREATE USER dbbackup PASSWORD 'password'

grant backup admin to dbbackup

grant catalog read to dbbackup

alter user dbbackup DISABLE PASSWORD LIFETIME

2、使用hdbuserstore 创建key sys_backup,prd_backup,po_backup用于连接数据库

3、构建备份脚本full_backup.sh

--daily full backup with file

#!/bin/bash

--获取当前的系统时间

prefix=`date +%Y_%m_%d_%H_%M_%S`

#指定连接数据库的key

sys_key='sys_backup'

prd_key='prd_backup'

pop_key='pop_backup'

#备份系统库SYSTEMDB

hdbsql -U $sys_key  "backup data using file ('COMPLETE_DATA_BACKUP_$prefix')"

sys_backupid=`hdbsql -U backup "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $sys_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $sys_backupid COMPLETE"

#备份租户库PRD

hdbsql -U $prd_key  "backup data  using file ('COMPLETE_DATA_BACKUP_$prefix')"

prd_backupid=`hdbsql -U $prd_key "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $prd_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $prd_backupid COMPLETE"

#备份租户库POP

hdbsql -U $pop_key  "backup data using file ('COMPLETE_DATA_BACKUP_$prefix')"

pop_backupid=`hdbsql -U test2backup "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $pop_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $pop_backupid COMPLETE"

--daily full backup with backint

#!/bin/bash

#获取当前的系统时间

prefix=`date +%Y_%m_%d_%H_%M_%S`

#指定连接数据库的key

sys_key='sys_backup'

prd_key='prd_backup'

pop_key='pop_backup'

#备份系统库SYSTEMDB

hdbsql -U $sys_key  "backup data using backint ('COMPLETE_DATA_BACKUP_$prefix')"

sys_backupid=`hdbsql -U backup "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $sys_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $sys_backupid COMPLETE"

#备份租户库PRD

hdbsql -U $prd_key  "backup data  using backint ('COMPLETE_DATA_BACKUP_$prefix')"

prd_backupid=`hdbsql -U $prd_key "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $prd_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $prd_backupid COMPLETE"

#备份租户库POP

hdbsql -U $pop_key  "backup data using backint ('COMPLETE_DATA_BACKUP_$prefix')"

pop_backupid=`hdbsql -U test2backup "select top 1 TO_BIGINT(REPLACE(BACKUP_ID,',','')) as backup_id 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" | sed -n '2p'`

#清理超过7天的备份文件以及catalog

hdbsql -U $pop_key "BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID $pop_backupid COMPLETE"

4、创建定时cron任务

crontab -e

###########daily full backup database at 23:30 ############

30 23 * * * /u03/dba_scripts/hana/full_backup.sh

标签:prd,backup,HANA,CATALOG,key,backupid,SAP,BACKUP,备份
From: https://www.cnblogs.com/oradba/p/17463891.html

相关文章

  • 课题设计备份
    importjavax.swing.*;importjavax.swing.border.Border;importjavax.swing.border.LineBorder;importjava.awt.*;importstaticjava.awt.FlowLayout.CENTER;publicclassMainextendsJFrame{publicMain(){//设置标题super("志文的小dem......
  • SAP HANA HASR 配置
    HANAHASR设置步骤,以SUSELINUX为例,RHEL类似:1、准备集群环境--安装SUSEHA需要的packagezypperin--typepatternha_sleszypperinSAPHanaSRSAPHanaSR-doc--配置基于共享存储的STONITH--创建SBD磁盘设备sbd-d /dev/sdc create--/dev/sdc需为集群共享磁盘--启动......
  • 为什么要备份数据? 如何做?
    什么是备份由于人为错误或外在因素也有机会掉失业务数据,需要恢复过往的数据来恢复业务,所以备份是需要做好的事,备份的层面很广,业务连系统一起备份,恢复时能原因相同的系统及日志记录,也可以只针对某应用程式备份,恢复只需要安装好此应用程式,经应用程式恢复备份的流程执......
  • rman测试备份跳过固定表空间后做全库恢复 (recover database skip tablespace )
    rman备份排除表空间:备份过程截图:备份脚本:run{allocatechannelt1devicetypedisk;allocatechannelt2devicetypedisk;backupascompressedbackupsetincrementallevel0filesperset10format'/u01/backup/data_%T_%U'database;sql'altersystemarc......
  • mysql数据自动备份脚本
    #!/bin/bash#日期date=$(date'+%Y%m%d')#设置备份目录和保留天数backup_dir="/opt/dbback"retention_days=7#数据库账密muser=mpasswd=mhost=#创建备份目录(如果不存在)mkdir-p$backup_dir#获取当前时间戳now=$(date+%s)#备份MySQL数据库到备份目......
  • Mysql 主从备份 Last_Errno: 1146 Last_Error: Error executing row event: 错误问题
    本人在做主从备份的时候发现了此问题! 1主数据库是已经把这个表删除了丛数据库也是没有备份这个表但是一直报这个错原因是bin-log日志有这个表 但是没记录到已经把这个表删除了 主从表同步实际从库是根据主库的bin-log二进制的SQL进行执行的 这是Mysql的一个BUG1......
  • GEE代码备份流程记录
    GEE代码备份流程记录这篇文章参考是穆老师的文章:GEE代码批量保存至本地(中秋快乐版)打开源码网址,将下面的YourUsername换成自己的用户名。https://earthengine.googlesource.com/users/YourUsername/或者通过下面的方法查看该网址:打开代码库分享设置,Gitclone后面的网址就是。......
  • Mysql数据备份
    导出库/表导出库:mysqldump-h主机-u用户-p密码数据库>目标路径导出表:mysqldump-h主机-u用户-p密码数据库表1表2表3...>目标路径例如:mysqldump-hlocalhost-uroot-p123456schoolt_studentt_grade>D:/sql/1.sql导入表/库(建议)如果在登录情况下,......
  • Windows server 2022 常见 备份事项
    以下是WindowsServer2022的DNS备份批处理脚本示例:CopyCode@echooffsetlocalrem定义备份路径setbackupPath=c:\dns_backup\rem获取当前日期时间作为备份文件名for/f"tokens=1-3delims=/"%%ain('date/t')doset"datestamp=%%a-%%b-%%c"for/f&q......
  • SAP Spartacus UI 中的 CmsTicketInterceptor
    在SpartacusUI发起的OCCAPI请求的URL中,您可能会注意到一个名为cmsTicketId的字段。这个字段的含义与用途如下:cmsTicketId是一个标识符,用于关联SpartacusUI与SAPCommerceCloud后端CMS(ContentManagementSystem)的会话。CMS是一个用于管理网站内容的系统,如......