rman多进程并发备份一个数据表空间脚本

原创 2016年11月10日 15:27:38
#!/bin/bash
export LANG=en_US
export ORACLE_HOME=/u01/app/product/10.2.0/db_1
export RMAN=$ORACLE_HOME/bin/rman
export ORACLE_SID=dbs1
export ORACLE_USER=oracle
export DAY=`date +%Y%m%d`  
export WEEKS=`date +%U`
export BACKUP_DIR=/u01/rman


export RMAN_LOG_FILE=$BACKUP_DIR/rman_"$ORACLE_SID"_$DAY.log

TODAY=`date`
USER=`id|cut -d "(" -f2|cut -d ")" -f1`
echo "=================$TODAY===================">$RMAN_LOG_FILE

echo "ORACLE_SID:  $ORACLE_SID">>$RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME">>$RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER">>$RMAN_LOG_FILE
echo "================================================================">>$RMAN_LOG_FILE
echo "                   ">>$RMAN_LOG_FILE
echo "BACKUP DATABASE BEGIN......">>$RMAN_LOG_FILE
echo "                   ">>$RMAN_LOG_FILE

chmod 666 $RMAN_LOG_FILE

BAK_LEVEL=0													       
#export BAK_LEVEL=$BAK_LEVEL
echo "Today is : `date +%A` incremental level $BAK_LEVEL">>$RMAN_LOG_FILE
echo "                   ">>$RMAN_LOG_FILE

RUN_STR="
export BAK_LEVEL=$BAK_LEVEL
export ORACLE_HOME=$ORACLE_HOME
export ORACLE_SID=$ORACLE_SID
$RMAN nocatalog TARGET / msglog $RMAN_LOG_FILE 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;
allocate channel c5 device type disk;
allocate channel c6 device type disk;
allocate channel c7 device type disk;
allocate channel c8 device type disk;
allocate channel c9 device type disk;
allocate channel c10 device type disk;
backup tag 'tstpcc' format '/u01/rman/tpcc_0_%d_%u' tablespace tpcc100;
sql 'alter system archive log current' ;
backup format '/u01/rman/archivelog_%d_%u' (archivelog all);
release channel c10;
release channel c9;
release channel c8;
release channel c7;
release channel c6;
release channel c5;
release channel c4;
release channel c3;
release channel c2;
release channel c1;
}
allocate channel for maintenance device type disk;
report obsolete;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
list backup summary;
release channel;
EOF
"

# Initiate the command string

if [ "$CUSER" = "root" ]
then
    echo "Root Command String: $RUN_STR" >> $RMAN_LOG_FILE    
    su - $ORACLE_USER -c "$RUN_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
else
    echo "User Command String: $RUN_STR" >> $RMAN_LOG_FILE    
    /bin/sh -c "$RUN_STR" >> $RMAN_LOG_FILE
    RSTAT=$?
fi

# ---------------------------------------------------------------------------
# Log the completion of this script.
# ---------------------------------------------------------------------------

if [ "$RSTAT" = "0" ]
then
    LOGMSG="ended successfully"
else
    LOGMSG="ended in error"
fi

echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
exit $RSTAT


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

rman 总结(附一个AIX的全备份脚本)

控制备份片的大小: 1、一次性(通过限制通道,来限制备份片的大小): run{ allocate channel d1 type disk; set limit channel di kbytes=1...

RMAN学习2——部分备份(表空间、数据文件)

1、表空间备份(其实是将该表空间下的所有数据文件进行备份) (1)RMAN> backup tablespace users; 启动 backup 于 17-7月 -12 使用通道 ORA_...

TSM备份ORACLE的rman脚本

  • 2013年07月02日 20:23
  • 38KB
  • 下载

oracle rman 备份与恢复 临时表空间的文件问题解决 留痕

---------- oracle rman 备份与恢复 ------ -- rman 自动备份脚本 2011/7/23 14:32:55 rman target / log=/oracle/bk_r...

rman备份策略及脚本

  • 2012年01月03日 13:12
  • 2KB
  • 下载

Oracle数据库RMAN的自动备份脚本

  • 2012年07月24日 11:31
  • 35KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:rman多进程并发备份一个数据表空间脚本
举报原因:
原因补充:

(最多只允许输入30个字)