加入收藏 | 设为首页 | 会员中心 | 我要投稿 济源站长网 (https://www.0391zz.cn/)- 数据工具、数据仓库、行业智能、CDN、运营!
当前位置: 首页 > 站长百科 > 正文

[Rman]Oracle Rman增量备份Level012脚本 - CSDN博客

发布时间:2021-03-05 06:03:44 所属栏目:站长百科 来源:网络整理
导读:Rman Level012备份实验http://blog.csdn.net/u011364306/article/details/50036429 采用0221222增量备份策略,7天一个轮回 也就是周日0级备份,周1 2 4 5 6 采用2级增量备份,周3采用1级增量备份 打开控制文件自动备份 [sql]view plaincopy CONFIGURE CONTROL
副标题[/!--empirenews.page--]

Rman Level012备份实验http://blog.csdn.net/u011364306/article/details/50036429

采用0221222增量备份策略,7天一个轮回

也就是周日0级备份,周1 2 4 5 6 采用2级增量备份,周3采用1级增量备份

打开控制文件自动备份

[sql]view plaincopy

  1. CONFIGURE CONTROLFILE AUTOBACKUP ON;?

11g控制文件自动备份新特性:http://blog.csdn.net/u011364306/article/details/50051303

配置控制文件备份路径

[sql]view plaincopy

  1. RMAN > CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO‘/file/backup/rman/controlfile_%F‘;?

将过期天数设为7天

[sql]view plaincopy

  1. RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;?

数据备份目录

[sql]view plaincopy

  1. $ mkdir -p /file/backup/rman/?

脚本解释:

[sql]view plaincopy

  1. vim rman_bak_level0.sh????
  2. #! /bin/bash??
  3. export ORACLE_BASE=/u01/oracle?
  4. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1?
  5. export PATH=$ORACLE_HOME/bin:$PATH?
  6. export ORACLE_SID=neal??? --数据库ORACLE_SID
  7. export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘--字符集
  8. rman target / <
  9. run{???
  10. allocate channel d1 type disk;?? --分配通道d1,类型备份到磁盘
  11. allocate channel d2 type disk;?? --分配通道d2,类型备份到磁盘
  12. backup incremental level 0 database format ‘/file/backup/rman/level0_%d_%s_%p_%u.bkp‘;?? --备份级别、输出格式、路径
  13. sql ‘alter system archive log current‘;??? --对当前redo日志进行归档
  14. backup archivelog alldelete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘;? --备份归档日志并删除
  15. crosscheck backup;?? --检查备份
  16. delete noprompt obsolete;? --静默删除过期备份
  17. release channel d1;? --释放通道d1
  18. release channel d2;? --释放通道d2
  19. }???
  20. EOF??

下面开始创建0级 1级 2级备份脚本

0级备份脚本

[sql]view plaincopy

  1. vim rman_bak_level0.sh?
  2. #! /bin/bash?
  3. export ORACLE_BASE=/u01/oracle?
  4. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1?
  5. export PATH=$ORACLE_HOME/bin:$PATH?
  6. export ORACLE_SID=neal?
  7. export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘
  8. rman target / <
  9. run{?
  10. allocate channel d1 type disk;?
  11. allocate channel d2 type disk;?
  12. backup incremental level 0 database format ‘/file/backup/rman/level0_%d_%s_%p_%u.bkp‘;?
  13. sql ‘alter system archive log current‘;?
  14. backup archivelog alldelete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘;?
  15. crosscheck backup;?
  16. delete noprompt obsolete;?
  17. release channel d1;?
  18. release channel d2;?
  19. }?
  20. EOF?

1级备份脚本

[sql]view plaincopy

  1. vim rman_bak_level1.sh?
  2. #! /bin/bash?
  3. export ORACLE_BASE=/u01/oracle?
  4. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1?
  5. export PATH=$ORACLE_HOME/bin:$PATH?
  6. export ORACLE_SID=neal?
  7. export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘
  8. rman target / <
  9. run{?
  10. allocate channel d1 type disk;?
  11. allocate channel d2 type disk;?
  12. backup incremental level 1 database format ‘/file/backup/rman/level1_%d_%s_%p_%u.bkp‘;?
  13. sql ‘alter system archive log current‘;?
  14. backup archivelog alldelete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘;?
  15. crosscheck backup;?
  16. delete noprompt obsolete;?
  17. release channel d1;?
  18. release channel d2;?
  19. }?
  20. EOF?

2级备份脚本

[sql]view plaincopy

  1. vim rman_bak_level2.sh?
  2. #! /bin/bash?
  3. export ORACLE_SID=neal?
  4. export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘
  5. /u01/oracle/product/11.2.0/db_1/bin/rman target / <
  6. run{?
  7. allocate channel d1 type disk;?
  8. allocate channel d2 type disk;?
  9. backup incremental level 2 database format ‘/file/backup/rman/level2_%d_%s_%p_%u.bkp‘;?
  10. sql ‘alter system archive log current‘;?
  11. backup archivelog alldelete input format ‘/file/backup/rman/archivelog_%d_%s_%p_%u.bkp‘;?
  12. crosscheck backup;?
  13. delete noprompt obsolete;?
  14. release channel d1;?
  15. release channel d2;?
  16. }?
  17. EOF?

加入到crontab中

[sql]view plaincopy

  1. crontab -e?
  2. #周日0级备份?
  3. 00 23 * * 0 /server/scripts/rman_bak_level0.sh?
  4. #周一、二、四、五、六2级增量备份?
  5. 00 23 * * 1,2,4,5,6 /server/scripts/rman_bak_level2.sh?
  6. #周三1级增量备份?
  7. 00 23 * * 3 /server/scripts/rman_bak_level1.sh?

Rman备份中变量的含义

backup incremental level 0 database format=‘LEV0_%d_%t_%U_%s_%p‘

format=string 文件路径和名称的格式串,其中可包含宏变量:

%c copy ID

%p backup piece ID

%s backup set ID

%e log sequence

%h log thread ID

%d database name

%n database name(x填充到8个字符)

%I DBID

%f file ID

%F DBID,day,month,year,and sequencer的复合

%N tablespace name

%t timestamp

%M mh mm格式

%Y year yyyy格式

%u backup set+time((x填充到8个字符)

%U %u_%p_%c

%% %

The format specifier %U is replaced with unique filenames for the files when you take backups.

(编辑:济源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读