Oracle 备份与恢复学习笔记(8)

第八章: Rman备份

1、rman备份分类:
    1)归档:可以做一致性和非一致性备份
    2)非归档:一致性备份
2、rman备份的分类:
    1)backupset  
  -------一致性备份
  RMAN> run {                                                                                                                              
2> shutdown immediate;                                                                                                                   
3> startup mount;                                                                                                                        
4> allocate channel c1 type disk;                                                                                                        
5> allocate channel c2 type disk;                                                                                                        
6> backup database format '/disk1/rman/prod/%d_%s.bak';                                                                                  
7> alter database open;                                                                                                                  
8> }       
  ---------非一致性备份
  RMAN> backup database format='/disk1/rman/prod/prod_%s.bak' filesperset 3;      
  RMAN> backup tablespace users format '/disk1/rman/prod/users_%s.bak' tag=userbak;
  RMAN> backup datafile 2,3,5   format '/disk1/rman/prod/%d_%s.bak';
  
    2)snapshot 镜像
    
  RMAN> copy datafile 2 to '/disk1/rman/prod/users_%s.bak'; 
  RMAN> backup as copy tablespace users format='/disk1/rman/prod/%d_users_%s.bak';
  
  [oracle@work ~]$ ls -lth /disk1/rman/prod
total 101M
-rw-r-----  1 oracle oinstall 101M Aug 18 06:12 users_15.bak
[oracle@work ~]$ 
-------生成的备份文件的大小和原datafile大小相同
 

3、增量备份:只备份发生变化的block(rman通过在备份时记录datablock的scn,下次备份时通过比较上次备份的数据块上的scn来确定数据块是否发生变化)
     1)差异增量备份(Differential incremental backup):下次备份时比较上次以来同级别或低级别的备份,为备份基础
     -----0级备份
     RMAN> backup incremental level 0 format '/disk1/rman/prod/users_0_%s.bak' tablespace users;
     RMAN> list backup;                                                                                                                      


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16      Incr 0  464.00K    DISK        00:00:01     18-AUG-11      
        BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: TAG20110818T064000
        Piece Name: /disk1/rman/prod/users_0_19.bak
  List of Datafiles in backup set 16
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2    0  Incr 1319567    18-AUG-11 /u01/app/oracle/oradata/prod/users01.dbf
     ------2级备份
     RMAN> backup incremental level 2 format '/disk1/rman/prod/users_2_%s.bak' tablespace users;
  BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18      Incr 2  112.00K    DISK        00:00:01     18-AUG-11      
        BP Key: 18   Status: AVAILABLE  Compressed: NO  Tag: TAG20110818T064135
        Piece Name: /disk1/rman/prod/users_2_21.bak
  List of Datafiles in backup set 18
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2    2  Incr 1319644    18-AUG-11 /u01/app/oracle/oradata/prod/users01.dbf
  ------1级备份
  RMAN> backup incremental level 1 format '/disk1/rman/prod/users_1_%s.bak' tablespace users; 
  BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
22      Incr 1  176.00K    DISK        00:00:01     18-AUG-11      
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20110818T064323
        Piece Name: /disk1/rman/prod/users_1_25.bak
  List of Datafiles in backup set 22
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2    1  Incr 1319760    18-AUG-11 /u01/app/oracle/oradata/prod/users01.dbf
  
     
     
     2)累积增量备份的区别:只比较比自己级别低的作为备份基础
     -------2级备份
     RMAN> backup incremental level 2 cumulative format '/disk1/rman/prod/users_2cu_%s.bak' tablespace users;
     -----1级备份
     RMAN> backup incremental level 1 cumulative format '/disk1/rman/prod/users_1cu_%s.bak' tablespace users; 
    

4、自动备份controlfile 和 spfile
 










本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/792495,如需转载请自行联系原作者
上一篇:Swift中文教程(一)--欢迎来到Swift的世界


下一篇:swift基础知识二