签到成功

知道了

CNDBA社区CNDBA社区

oracle rman备份脚本

2022-03-23 14:29 1137 0 原创 oracle
作者: hbhe0316

oracle rman备份脚本,支持Linux,AIX平台,不需要输入库名,针对多库环境,未做判断。http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894

http://www.cndba.cn/hbhe0316/article/107894
http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894http://www.cndba.cn/hbhe0316/article/107894

#!/bin/ksh
osbox=`uname`
if [[ $osbox == "Linux" ]];then
        SID_NUM=`ps -ef | grep ora_smon | grep -v grep | awk -F ' ' {'print $8'} | awk -F '_' {'print $3'} | wc -l`
        if [[ $SID_NUM -ne 1 ]];then
                exit 1
        fi
        SID_ENV=`ps -ef | grep ora_smon | grep -v grep | awk -F ' ' {'print $8'} | awk -F '_' {'print $3'}`
elif [[ $osbox == "AIX" ]];then
        SID_NUM=`ps -ef | grep ora_smon | grep -v grep | awk -F ' ' {'print $9'} | awk -F '_' {'print $3'} | wc -l`
        if [[ $SID_NUM -ne 1 ]];then
                exit 1
        fi
        SID_ENV=`ps -ef | grep ora_smon | grep -v grep | awk -F ' ' {'print $9'} | awk -F '_' {'print $3'}`
else
        echo "Current os does not support."
        exit 1
fi
#SID_ENV=`/bin/env|grep ORACLE_SID|awk -F '=' '{print $2}'`
export NLS_DATE_FORMAT='yyyymmdd hh24:mi:ss'
HOST=`hostname`
export ORACLE_SID=`echo $SID_ENV`
CUR_DATE="`date +%Y-%m-%d`"
mkdir -p /mnt/backup/DB/ORACLE/${HOST}_${SID_ENV}_${CUR_DATE}
DIR=$(cd /mnt/backup/DB/ORACLE/${HOST}_${SID_ENV}_${CUR_DATE};pwd)
echo $DIR
rman target / log $DIR/full_backup.log append << EOF
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup as compressed backupset filesperset 3 database format '$DIR/full_%d_%T_%s_%p';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog from time 'sysdate-1' format '$DIR/arch_%d_%T_%s_%p';
backup spfile format '$DIR/spfile_%d_%T_%s_%p';
backup current controlfile format '$DIR/ctl_%d_%T_%s_%p';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
EOF

版权声明:本文为博主原创文章,未经博主允许不得转载。

oracle

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1039051次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ