Oracle生產環境RMAN備份指令碼

xz43發表於2014-05-08

題記:這裡分享一下我們oracle的備份指令碼,這些指令碼均在生產庫執行,正確無誤!

環境:SUSE linux 10sp2 + oracle 11gr1

說明:小型庫一般都是每週做一次全備,大型庫每週也做一次全備外,週三做1級增量備份,然後每天晚上都做一次2級增量備份,歸檔日誌每天分不同時段定時備份!

小型庫全備:
run {
  # Hot database level 0 whole backup
  allocate channel t1 type disk;
  backup
      incremental level 0
      skip inaccessible
      format '/backup/osedb_osedb01/data/back_%s_%p_%T_%d'
  #AS COMPRESSED backupset
  database plus archivelog
  format '/backup/osedb_osedb01/arch/arclogback_%s_%p_%t_%d' 
  delete input;
  delete obsolete;
  release CHANNEL t1 ;
}

 

大庫全備:
> cat backup_db_level0.cmd
run {
  # Hot database level 0 whole backup
  allocate channel t1 type disk maxpiecesize=50G;
  allocate channel t2 type disk maxpiecesize=50G;
  allocate channel t3 type disk maxpiecesize=50G;
  backup as compressed backupset
      incremental level 0 tag 'subsdb_level0'
      skip inaccessible
      format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_%p_db_level0'
  #AS COMPRESSED backupset
  database 
  plus archivelog
  format '/backup/subsdb_subsdb1/arch/arclogback_%s_%p_%t_%d' 
  delete input;
  backup current controlfile format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_ctl.ctl';
  release channel t1;
  release channel t2;
  release channel t3;
  delete noprompt obsolete;
}

1級增量備份:
> cat backup_db_level1.cmd
run {
  # Hot database level 1 whole backup
  allocate channel t1 type disk maxpiecesize=50G;
  allocate channel t2 type disk maxpiecesize=50G;
  allocate channel t3 type disk maxpiecesize=50G;
  backup as compressed backupset
      incremental level 1 tag 'subsdb_level1'
      skip inaccessible
      format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_%p_db_level1'
  #AS COMPRESSED backupset
  database plus archivelog
  format '/backup/subsdb_subsdb1/arch/arclogback_%s_%p_%t_%d' 
  delete input;
  backup current controlfile format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_ctl.ctl';
  release channel t1;
  release channel t2;
  release channel t3;
  delete noprompt obsolete;
}

2級增量備份:
> cat backup_db_level2.cmd
run {
  # Hot database level 2 whole backup
  allocate channel t1 type disk maxpiecesize=50G;
  allocate channel t2 type disk maxpiecesize=50G;
  allocate channel t3 type disk maxpiecesize=50G;
  backup as compressed backupset
      incremental level 2 tag 'subsdb_level2'
      skip inaccessible
      format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_%p_db_level2'
  #AS COMPRESSED backupset
  database
  plus archivelog
  format '/backup/subsdb_subsdb1/arch/arclogback_%s_%p_%t_%d' 
  delete input;
  backup current controlfile format '/backup/subsdb_subsdb1/data/bak_%d_%T_%s_ctl.ctl';
  release channel t1;
  release channel t2;
  release channel t3;
  delete noprompt obsolete;
}


歸檔日誌備份:
cat backup_arch.cmd 
run {

  allocate channel t1 type disk;
  backup
    skip inaccessible
    format '/backup/osedb_osedb01/arch/arclogback_%s_%p_%t_%d'
    #AS COMPRESSED backupset 
   (archivelog all delete input); 
   delete obsolete;
  release CHANNEL t1 ;
}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-1156945/,如需轉載,請註明出處,否則將追究法律責任。

相關文章