sid=`ps -ef|grep smon |egrep -v "+ASM|grep|opt"|awk '{print $8}'|awk -F "_" '{print $3}'`
for id in $sid
do
echo $id
export ORACLE_SID=$id
echo $ORACLE_SID
##backup
##backup_time as dir
DATE=`date '+%Y-%m-%d-%H'`
cd /backup/bak3_1/
mkdir $DATE
cd $DATE
mkdir $ORACLE_SID
cd $ORACLE_SID
mkdir archivebackup
#source $ORACLE_HOME/bin/
rman msglog=/backup/bak3_1/$DATE/$ORACLE_SID/bak.log << EOF
connect target
RUN {
crosscheck backup;
delete noprompt expired backup;
report obsolete;
delete noprompt obsolete;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup full database format '/backup/bak3_1/$DATE/$ORACLE_SID/bak_%U_%s_%T.db';
release channel c1;
release channel c2;
sql 'alter system archive log current';
allocate channel d1 type disk MAXPIECESIZE = 4G;
allocate channel d2 device type disk;
backup archivelog all format '/backup/bak3_1/$DATE/$ORACLE_SID/archivebackup/arc_%d_%s_%p.bak' delete all input;;
backup spfile format '/backup/bak3_1/spfilerman_%s_%t';
release channel d1;
release channel d2;
allocate channel d3 device type disk;
backup format '/backup/bak3_1/$DATE/$ORACLE_SID/contrl_%s_%p_%t' current controlfile;
release channel d3;
}
exit;
EOF
done
客户存储环境异常,临时要备份10几套数据库,懒得一个个数据库写备份脚本,临时写了一个集中批量rman 备份的脚本;