Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2374869
  • 博文数量: 200
  • 博客积分: 2413
  • 博客等级: 大尉
  • 技术积分: 3067
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-01 22:07
文章分类

全部博文(200)

文章存档

2018年(2)

2017年(8)

2016年(35)

2015年(14)

2014年(20)

2013年(24)

2012年(53)

2011年(44)

分类: Oracle

2011-12-27 17:22:15

采用0112111增量备份策略,7天一个轮回
也就是周日0级备份,周1 2 4 5 6 采用2级增量备份,周3采用1级增量备份

配置控制文件备份路径
  1. RMAN > CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/rmanbk/ccontrolfile_%F';
数据备份目录
  1. $ mkdir -p /u01/backup/rmanbk
首先将过期天数设为7天
  1. RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
下面开始创建0级 1级 2级备份脚本

0级备份脚本
  1. vim rman_bk_level0.sh
  2. ------0级备份----------------
  3. #! /bin/bash
  4. export ORACLE_SID=orcl
  5. export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'
  6. /u01/app/oracle/11.2.0/dbhome_1/bin/rman target / <<EOF
  7. run{
  8. allocate channel d1 type disk;
  9. allocate channel d2 type disk;
  10. backup incremental level 0 database format '/u01/backup/rmanbk/level0_%d_%s_%p_%u.bkp';
  11. sql 'alter system archive log current';
  12. backup archivelog all delete input format '/u01/backup/rmanbk/log_%d_%s_%p_u%.bkp';
  13. }
  14. crosscheck backup;
  15. delete noprompt obsolete;
  16. exit;
  17. <<EOF
  18. ------------------

1级备份脚本
  1. vim rman_bk_level1.sh
  2. ---------1级增量备份---------------
  3. #! /bin/bash
  4. export ORACLE_SID=orcl
  5. export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'
  6. /u01/app/oracle/11.2.0/dbhome_1/bin/rman target / <<EOF
  7. run{
  8. allocate channel d1 type disk;
  9. allocate channel d2 type disk;
  10. backup incremental level 1 database format '/u01/backup/rmanbk/level1_%d_%s_%p_%u.bkp';
  11. sql 'alter system archive log current';
  12. backup archivelog all delete input format '/u01/backup/rmanbk/log_%d_%s_%p_u%.bkp';
  13. }
  14. crosscheck backup;
  15. delete noprompt obsolete;
  16. exit;
  17. <<EOF

2级备份脚本
  1. vim rman_bk_level2.sh
  2. ---------2级增量备份---------------
  3. #! /bin/bash
  4. export ORACLE_SID=orcl
  5. export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'
  6. /u01/app/oracle/11.2.0/dbhome_1/bin/rman target / <<EOF
  7. run{
  8. allocate channel d1 type disk;
  9. allocate channel d2 type disk;
  10. backup incremental level 2 database format '/u01/backup/rmanbk/level2_%d_%s_%p_%u.bkp';
  11. sql 'alter system archive log current';
  12. backup archivelog all delete input format '/u01/backup/rmanbk/log_%d_%s_%p_u%.bkp';
  13. }
  14. crosscheck backup;
  15. delete noprompt obsolete;
  16. release d1;
  17. exit;
  18. <<EOF


加入到crontab中
  1. crontab -e
  2. -----------
  3. #周日0级备份
  4. 00 23 * * 0 /u01/backup_shell/rman_bk_level0.sh
  5. #周一、二、四、五、六2级增量备份
  6. 00 23 * * 1,2,4,5,6 /u01/backup_shell/rman_bk_level2.sh
  7. #周三1级增量备份
  8. 00 23 * * 3 /u01/backup_shell/rman_bk_level1.sh
  9. -------------

结束!
阅读(7924) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~