首页 > 代码库 > Oracle RMAN 备份一例
Oracle RMAN 备份一例
Oracle RMAN备份一例:
Solaris 10 + Oracle 11.2.0.3
Shell:csh
备份策略:周日0级备份,周一~周六1级备份,每6小时备份归档日志,每天清理历史文件夹.
--0级备份脚本:
--1级备份脚本:
--归档备份
--系统级别删除过期备份的空文件夹
--crontab调度
crontab -l
#!/bin/csh#db0 level backupfoldername=`date +%Y%m%d`cd /oradata1/backupif [ -d $foldername ]then echo ‘go on‘else echo ‘need mkdir‘ mkdir $foldernamefiset ORACLE_SID SHIRNOPset ORACLE_BASE /opt/app/oracle/set ORACLE_HOME /opt/app/oracle/product/11.2.0/dbhome_1/set NLS_LANG "simplified chinese_china.ZHS16GBK"set NLS_DATE_FORMAT "YYYY-MM-DD HH24:Mi:SS"set PATH /bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target / log=/oradata1/backup/$foldername/full_LOG_%U.log << RMAN_BACKUPrun{CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oradata1/backup/$foldername/controlfile%F‘;allocate channel c1 device type disk;allocate channel c2 device type disk;backup incremental level 0 tag ‘db0‘ database format ‘/oradata1/backup/$foldername/db0_%d_%T_%s‘ include current controlfile;delete noprompt obsolete;release channel c1;release channel c2;}RMAN_BACKUP
#!/bin/csh#db1 level backupfoldername=`date +%Y%m%d`cd /oradata1/backupif [ -d $foldername ]then echo ‘go on‘else echo ‘need mkdir‘ mkdir $foldernamefiset ORACLE_SID SHIRNOPset ORACLE_BASE /opt/app/oracle/set ORACLE_HOME /opt/app/oracle/product/11.2.0/dbhome_1/set NLS_LANG "simplified chinese_china.ZHS16GBK"set NLS_DATE_FORMAT "YYYY-MM-DD HH24:Mi:SS"set PATH /bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target / log=/oradata1/backup/$foldername/incr_LOG_%U.log << RMAN_BACKUPrun{CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oradata1/backup/$foldername/controlfile%F‘;allocate channel c1 device type disk;allocate channel c2 device type disk;backup incremental level 1 tag ‘db1‘ database format ‘/oradata1/backup/$foldername/db1_%d_%T_%s‘ include current controlfile;delete noprompt obsolete;release channel c1;release channel c2;}RMAN_BACKUP
#!/bin/csh#arch backupfoldername=`date +%Y%m%d`cd /oradata1/backupif [ -d $foldername ]then echo ‘go on‘else echo ‘need mkdir‘ mkdir $foldernamefiset ORACLE_BASE /opt/app/oracle/set ORACLE_HOME /opt/app/oracle/product/11.2.0/dbhome_1/set ORACLE_SID SHIRNOPset NLS_LANG "simplified chinese_china.ZHS16GBK"set NLS_DATE_FORMAT "YYYY-MM-DD HH24:Mi:SS"set PATH /bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target / log=/oradata1/backup/$foldername/arch_LOG_%U.log << RMAN_BACKUPrun{CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;allocate channel c1 device type disk;allocate channel c2 device type disk;sql ‘alter system archive log current‘;backup archivelog all delete input format ‘/oradata1/backup/$foldername/arch_%d_%T_%s‘;release channel c1;release channel c2;}crosscheck archivelog all;delete expired archivelog all;RMAN_BACKUP
#!/bin/bash#del old folderscd /oradata1/backupfind . -mtime +10 | xargs rm -rf
crontab -l
0 1 * * 0 /oradata1/backupsh/db0_backup.rman > /dev/null 2&>1#0 1 * * 1-6 /oradata1/backupsh/db1_backup.rman > /dev/null 2&>1#0 6,12,18 * * * /oradata1/backupsh/arch_backup.rman > /dev/null 2&>1#0 3 * * * /oradata1/backupsh/del_old.sh > /dev/null 2&>1#
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。