Oracle数据库之oracle全量、增量备份
小标 2018-09-10 来源 : 阅读 5695 评论 0

摘要:本文主要向大家介绍了Oracle数据库之oracle全量、增量备份,通过具体的内容向大家展现,希望对大家学习Oracle数据库有所帮助。

本文主要向大家介绍了Oracle数据库之oracle全量、增量备份,通过具体的内容向大家展现,希望对大家学习Oracle数据库有所帮助。

采用0221222增量备份策略,7天一个轮回
也就是周日0级备份,周1 2 4 5 6 采用2级增量备份,周3采用1级增量备份
打开控制文件自动备份
CONFIGURE CONTROLFILE AUTOBACKUP ON; 
配置控制文件备份路径
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/file/backup/rman/controlfile_%F‘; 
将过期天数设为7天
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; 
---全备
vim rman_bak_level0.sh    
#! /bin/bash  
export ORACLE_BASE=/u01/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 
export PATH=$ORACLE_HOME/bin:$PATH 
export ORACLE_SID=neal    --数据库ORACLE_SID 
export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘   --字符集 
rman target / <<EOF    run{    allocate channel d1 type disk;   --分配通道d1,类型备份到磁盘 
allocate channel d2 type disk;   --分配通道d2,类型备份到磁盘 
backup incremental level 0 database format ‘/file/backup/rman/level0_%d_%s_%p_%u.bkp‘;   --备份级别、输出格式、路径 
sql ‘alter system archive log current‘;    --对当前redo日志进行归档 
backup archivelog all delete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘;  --备份归档日志并删除 
crosscheck backup;   --检查备份 
delete noprompt obsolete;  --静默删除过期备份 
release channel d1;  --释放通道d1 
release channel d2;  --释放通道d2  }   
EOF  
---0级备份脚本
vim rman_bak_level0.sh 
#! /bin/bash 
export ORACLE_BASE=/u01/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 
export PATH=$ORACLE_HOME/bin:$PATH 
export ORACLE_SID=neal 
export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘ 
rman target / <<EOF 
run{  allocate channel d1 type disk; 
allocate channel d2 type disk; 
backup incremental level 0 database format ‘/file/backup/rman/level0_%d_%s_%p_%u.bkp‘; 
sql ‘alter system archive log current‘;  backup archivelog all delete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘; 
crosscheck backup; 
delete noprompt obsolete; 
release channel d1; 
release channel d2;  } 
EOF 
--1级备份脚本
vim rman_bak_level1.sh 
#! /bin/bash 
export ORACLE_BASE=/u01/oracle 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 
export PATH=$ORACLE_HOME/bin:$PATH 
export ORACLE_SID=neal 
export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘ 
rman target / <<EOF 
run{  allocate channel d1 type disk; 
allocate channel d2 type disk; 
backup incremental level 1 database format ‘/file/backup/rman/level1_%d_%s_%p_%u.bkp‘; 
sql ‘alter system archive log current‘;  backup archivelog all delete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘; 
crosscheck backup; 
delete noprompt obsolete; 
release channel d1; 
release channel d2;  } 
EOF 
--2级备份脚本
vim rman_bak_level2.sh 
#! /bin/bash  export ORACLE_SID=neal 
export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘ 
/u01/oracle/product/11.2.0/db_1/bin/rman target / <<EOF 
run{  allocate channel d1 type disk; 
allocate channel d2 type disk;  backup incremental level 2 database format ‘/file/backup/rman/level2_%d_%s_%p_%u.bkp‘; 
sql ‘alter system archive log current‘; 
backup archivelog all delete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘; 
crosscheck backup; 
delete noprompt obsolete; 
release channel d1; 
release channel d2;  } 
EOF 
 
--加入到crontab中
crontab -e 
#周日0级备份  00 23 * * 0 /server/scripts/rman_bak_level0.sh 
#周一、二、四、五、六2级增量备份  00 23 * * 1,2,4,5,6 /server/scripts/rman_bak_level2.sh 
#周三1级增量备份  00 23 * * 3 /server/scripts/rman_bak_level1.sh 

本文由职坐标整理并发布,希望对同学们学习Oracle有所帮助,更多内容请关注职坐标数据库Oracle数据库频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved