码迷,mamicode.com
首页 > 数据库 > 详细

Oracle RMAN 备份一例

时间:2014-07-19 08:29:14      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   文件   io   

Oracle RMAN备份一例:
Solaris 10 + Oracle 11.2.0.3
Shell:csh
备份策略:周日0级备份,周一~周六1级备份,每6小时备份归档日志,每天清理历史文件夹.
--0级备份脚本:
#!/bin/csh
#db0 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    ‘go on‘
else
        echo    ‘need mkdir‘
        mkdir $foldername
fi

set ORACLE_SID SHIRNOP
set 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_BACKUP
run{
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
--1级备份脚本:
#!/bin/csh
#db1 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    ‘go on‘
else
        echo    ‘need mkdir‘
        mkdir $foldername
fi

set ORACLE_SID SHIRNOP
set 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_BACKUP
run{
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 backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    ‘go on‘
else
        echo    ‘need mkdir‘
        mkdir $foldername
fi

set ORACLE_BASE /opt/app/oracle/
set ORACLE_HOME /opt/app/oracle/product/11.2.0/dbhome_1/
set ORACLE_SID SHIRNOP
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/arch_LOG_%U.log << RMAN_BACKUP
run{
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 folders
cd /oradata1/backup
find . -mtime +10 | xargs rm -rf
--crontab调度
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#

 

Oracle RMAN 备份一例,布布扣,bubuko.com

Oracle RMAN 备份一例

标签:style   blog   color   os   文件   io   

原文地址:http://www.cnblogs.com/jyzhao/p/3809099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!