单机环境全备
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=hncdfpos001
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$ORACLE_HOME/bin:$PATH
rman target / log /backup/hncdfpos001/rman_full.log append<<EOF
run
{allocate channel c1 type disk;
allocate channel c2 type disk;
backup database filesperset 4 format '/backup/hncdfpos001/full_%d_%T_%s_%p';
sql 'alter system archive log current';
backup archivelog all format '/backup/hncdfpos001/arch_%d_%T_%s_%p' delete input;
backup current controlfile format '/backup/hncdfpos001/ctl_%d_%T_%s_%p';
crosscheck backup;
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt expired backup;
delete noprompt expired archivelog all;
}
EOF
单机环境备归档
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=hncdfpos001
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$ORACLE_HOME/bin:$PATH
rman target / log /backup/hncdfpos001/rman_arch.log append<<EOF
run
{allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system archive log current';
backup archivelog all format '/backup/hncdfpos001/arch_%d_%T_%s_%p' delete input;
backup current controlfile format '/backup/hncdfpos001/ctl_%d_%T_%s_%p';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
}
EOF
RAC环境全备
run {
allocate channel c1 device type disk connect 'sys/Oracle11@rac101';
allocate channel c2 device type disk connect 'sys/Oracle11@rac102';
backup database database format '/backup/rmanbak/db_full_%T_%d_%t_%s_%p_bak0';
sql 'alter system archive log current';
backup archivelog all format '/backup/rmanbak/arch_%T_%d_%t_%s_%p_bak0' delete input;
backup current controlfile format '/backup/rmanbak/controlfile_%T_%d_%t_%s_%p_bak0';
backup spfile format '/backup/rmanbak/spfile_%T_%d_%t_%s_%p_bak0';
crosscheck backup;
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt expired backup;
delete noprompt expired archivelog all;
release channel c1;
release channel c2;
}