共享出自己前段时间为客户写的一个数据库的备份脚本。
#!/bin/bash
#oracle env
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
export ORACLE_OWNER=oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=yjsdb
export LANG=en_US
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
##backup
DATE=`date '+%Y-%m-%d-%H'`
cd /backup/yjsdb/
mkdir $DATE
cd $DATE
mkdir archivebackup
$ORACLE_HOME/bin/rman<<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;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup full skip inaccessible tag yjsdb$DATE filesperset 5 format '/backup/yjsdb/$DATE/bak_%U_%s_%T.db' (database);
release channel c1;
release channel c2;
release channel c3;
release channel c4;
sql 'alter system archive log current';
allocate channel d1 type disk MAXPIECESIZE = 4G;
allocate channel c2 device type disk;
backup tag yjsdb_arc$DATE archivelog all format='/backup/yjsdb/$DATE/archivebackup/arc_%d_%s_%p.bak' delete all input;
backup spfile format '/backup/yjsdb/$DATE/spfileYJSDB_%s_%t';
release channel d1;
release channel d2;
allocate channel d3 device type disk;
backup tag yjsdb_ctl$DATE format '/backup/yjsdb/$DATE/contrl_%s_%p_%t' current controlfile;
release channel d31;
}
exit;
EOF
|
阅读(6206) | 评论(0) | 转发(1) |