这两天在测试rman的备份恢复【累计增量备份】(测试完将放到东莞正式环境中,其中还有许多没考虑到的地方,慢慢改进)
备份方式:每个月做一次数据库的全备,每周周末进行数据库的0级备份,周1,2,4,5,6进行2级备份,周3进行1级备份。
FULL_BACKUP
#!/bin/bash
#this is rman auto full backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup database filesperset 3 format '/backup/rman_full_bak/ora_full_%d_%t%s%p%u';
sql 'alter system archive log current';
backup archivelog all format '/backup/arc_bak/arc_log_%d_%s_%p_%u' delete all input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
#this is rman auto full backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup database filesperset 3 format '/backup/rman_full_bak/ora_full_%d_%t%s%p%u';
sql 'alter system archive log current';
backup archivelog all format '/backup/arc_bak/arc_log_%d_%s_%p_%u' delete all input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
BACKUP_L0:
#!/bin/bash
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level 0 database format '/backup_rman/rman_L0/ora_full_%d_%t%s%p%u';
sql 'alter system archive log current';
backup archivelog all format '/backup_rman/arc_bak/arc_log_%d_%s_%p_%u' delete all input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level 0 database format '/backup_rman/rman_L0/ora_full_%d_%t%s%p%u';
sql 'alter system archive log current';
backup archivelog all format '/backup_rman/arc_bak/arc_log_%d_%s_%p_%u' delete all input;
release channel c1;
release channel c2;
release channel c3;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
BACKUP_L1:
#!/bin/bash
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
#set env
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
#login and begin backup
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup incremental level 1 cumulative database format '/backup_rman/rman_L1_bak/ora_full_%d_%t%s%p%u';
release channel c1;
release channel c2;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
#set env
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
#login and begin backup
./rman target / nocatalog <run{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup incremental level 1 cumulative database format '/backup_rman/rman_L1_bak/ora_full_%d_%t%s%p%u';
release channel c1;
release channel c2;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
BACKUP_L2:
#!/bin/bash
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
backup incremental level 2 cumulative database format '/backup_rman/rman_L2_bak/ora_full_%d_%t%s%p%u';
release channel c1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
#this is rman auto LEVEL 0 backup script
#Copyright by frog
#date 2009-11-07
#
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/10g
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NL33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=/bin:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:$PATH
export PATH=$PATH:/opt/local/bin
cd $ORACLE_HOME/bin
./rman target / nocatalog <run{
allocate channel c1 type disk;
backup incremental level 2 cumulative database format '/backup_rman/rman_L2_bak/ora_full_%d_%t%s%p%u';
release channel c1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22779391/viewspace-619328/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22779391/viewspace-619328/