标签:system spfile gms not profile port 1.2 delete lte
一.rman备份脚本并为定时任务
#!/bin/bash
source ~/.bash_profile
export LANG=en_US
BACKUP_DATE=`date +%d`
#RMAN_LOG_FILE=${0}.out
RMAN_LOG_FILE=backupinfo.out
TODAY=`date`
USER=`id|cut -d "(" -f2|cut -d")" -f1`
echo "---------------$TODAY--------------"
#export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export RMAN=$ORACLE_HOME/bin/rman
export ORACLE_SID=DB11G
export ORACLE_USER=oracle
echo 1
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 "BACKUP DATABASE BEGIN......">>$RMAN_LOG_FILE
echo " ">>$RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
echo 2
WEEK_DAILY=`date +%a`
case "$WEEK_DAILY" in
"Mon")
BAK_LEVEL=2
;;
"Tue")
BAK_LEVEL=2
;;
"Wed")
BAK_LEVEL=2
;;
"Thu")
BAK_LEVEL=1
;;
"Fri")
BAK_LEVEL=2
;;
"Sat")
BAK_LEVEL=2
;;
"Sun")
BAK_LEVEL=0
;;
"*")
BAK_LEVEL=error
esac
export BAK_LEVEL=$BAK_LEVEL
echo "Today is : $WEEK_DAILY incremental level= $BAK_LEVEL">>$RMAN_LOG_FILE
run1="
BAK_LEVEL=$BAK_LEVEL;
export BAK_LEVEL
ORACLE_HOME=$ORACLE_HOME;
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID;
export ORACLE_SID
$RMAN target sys/******@DB11G msglog $RMAN_LOG_FILE append <<EOF
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup incremental level= $BAK_LEVEL skip inaccessible filesperset 5 Database format=‘/oracletemp/DB11G/rmanbackup/ora11g_lev"$BAK_LEVEL"_%U_%T‘ tag=‘ora11g_lev"$BAK_LEVEL"‘;
sql ‘alter system archive log current‘;
backup archivelog all tag=‘arc_bak‘ format=‘/oracletemp/DB11G/rmanbackup/archivelog_%U_%T‘ skip inaccessible filesperset 5 not backed up 1 times delete input;
backup current controlfile tag=‘bak_ctlfile‘ format=‘/oracletemp/DB11G/rmanbackup/ctl_file_%U_%T‘;
backup spfile tag=‘spfile‘ format=‘/oracletemp/DB11G/rmanbackup/ora11g_spfile_%U_%T‘;
release channel c2;
release channel c1;
}
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
list backup summary;
EOF
"
#+--------------------------------------------------------------+
#| Initiate the command string
#+--------------------------------------------------------------+
if [ "$CUSER" = "root" ]
then
echo "Root Command String: $run1" >> $RMAN_LOG_FILE
su - $ORACLE_USER -c "$run1" >> $RMAN_LOG_FILE
RSTAT=$?
else
echo "User Command String: $run1" >> $RMAN_LOG_FILE
/bin/sh -c "$run1" >> $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
<<EOF
#+--------------------------------------------------------------+
#| The end.
#+--------------------------------------------------------------+
二.异机恢复
在备份机器上面安装数据库软件,新建相应的目录及配置权限。(尴尬)做的恢复笔记找不到了。
有时间再来一次。
---------------我是有底线的--------------------
作者:jt
出处:http://www.cnblogs.com/Jt00/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
如果文中有什么错误,欢迎指出。以免更多的人被误导。
标签:system spfile gms not profile port 1.2 delete lte
原文地址:http://www.cnblogs.com/Jt00/p/6766928.html