阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Oracle RMAN 备份一例

201次阅读
没有评论

共计 3617 个字符,预计需要花费 10 分钟才能阅读完成。

Oracle RMAN 备份一例:
Solaris 10 + Oracle 11.2.0.3
Shell:csh, 安装有 bash, 脚本调用 bash
备份策略:周日 0 级备份, 周一~ 周六 1 级备份, 每 6 小时备份归档日志, 每天清理历史文件夹.
–0 级备份脚本:
#!/bin/bash
#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
 
export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.
 
rman target /  log=/oradata1/backup/$foldername/full_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 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;
allocate channel c3 device type disk;
allocate channel c4 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;
release channel c3;
release channel c4;
}
RMAN_BACKUP
 
–1 级备份脚本:
 
#!/bin/bash
#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
 
export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.
 
rman target /  log=/oradata1/backup/$foldername/incr_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 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;
allocate channel c3 device type disk;
allocate channel c4 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;
release channel c3;
release channel c4;
}
RMAN_BACKUP
 
– 归档备份
 
#!/bin/bash
#arch backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [-d $foldername ]
then
        echo    'go on'
else
        echo    'need mkdir'
        mkdir $foldername
fi
 
export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.
 
rman target /  log=/oradata1/backup/$foldername/arch_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 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 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-08/146099.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计3617字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中