linuxの下でrmanの簡単なバックアップポリシーと計画タスク


今回のプレゼンテーションはrmanバックアップおよび対応する計画タスクです.
RMANバックアップポリシー
全体的なポリシーは、10日以内にリカバリ可能なデータ、水曜日と土曜日のレベル0バックアップ、アーカイブ・ログの毎日のバックアップです.
--以下はいくつかのバックアップポリシーの構成です:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 10 DAYS;--10日間のデータのrmanバックアップをリストア
CONFIGURE CONTROLFILE AUTOBACKUP ON;--制御ファイルの自動バックアップ
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/datarman/rmanbak/controlfile/%F';--制御ファイルの自動ディレクトリ
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/datarman/rmanbak/controlfile/snapcf_emoss2.f';--ファイルスナップショットの制御
--バックアップのパスは次のとおりです.--アーカイブのバックアップパス:/datarman/rmanbak/arch/
--ファイルバックアップパスの制御:/datarman/rmanbak/controlfile/
--データベース・ファイルのバックアップ・パス:/datarman/rmanbak/dbfile/
--データベースファイルバックアップログパス:/datarman/rmanbak/dbfile_log/
以下はバックアップスクリプト(スクリプトパス:/datarman/rmanbak/dbrman_scripts)です.
--余分なバックアップスクリプトと無効なバックアップスクリプトを削除(毎日削除)
[oracle@localhost dbrman_scripts]$ chmod u+x delobsolete
[oracle@localhost dbrman_scripts]$ vi  delobsolete
run {
   crosscheck backup;
   delete noprompt obsolete;
   delete noprompt expired backup;
}

--アーカイブログスクリプトのバックアップ(毎日バックアップ)
[oracle@localhost dbrman_scripts]$ chmod u+x arch
[oracle@localhost dbrman_scripts]$ vi  arch
sql 'alter system archive log current' ;
run {
allocate channel a1 type disk  FORMAT   '/datarman/rmanbak/arch/' ;
backup filesperset 10 format '/datarman/rmanbak/arch/arch_%T_%d_%t_%s_%p' archivelog all delete input;
release channel a1;
}

--データベースレベル0のバックアップ・スクリプト(毎週3~土曜日)
[oracle@localhost dbrman_scripts]$ chmod u+x level0
[oracle@localhost dbrman_scripts]$ vi  level0
sql 'alter system archive log current' ;
run {
allocate channel a2 type disk  ;
backup as compressed backupset incremental level 0 DATABASE filesperset 5  format '/datarman/rmanbak/dbfile/db_%T_%d_%t_%s_%p' ;
release channel a2;
}

対応するshell実行スクリプト
--余分なバックアップ・スクリプトと無効なバックアップ・スクリプトを削除します(毎日1時に削除)
[oracle@localhost dbrman_scripts]$ chmod u+x emoss2dbdel.sh
[oracle@localhost dbrman_scripts]$ vi emoss2dbdel.sh
export ORACLE_SID=orcl  
export ORACLE_BASE=/u01/app/oracle  
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1  
export LD_LIBRARY_PATH=$ORACLE_HOME/lib  
export PATH=$PATH:$ORACLE_HOME/bin
export NAME=`date -d now +%F`
$ORACLE_HOME/bin/rman target /  nocatalog  log=/datarman/rmanbak/dbfile_log/emoss2dbrmandel_$NAME.log<

----アーカイブログスクリプトのバックアップ(毎日2時バックアップ)
[oracle@localhost dbrman_scripts]$ chmod u+x emoss2dbarch.sh
[oracle@localhost dbrman_scripts]$ vi emoss2dbarch.sh
export ORACLE_SID=orcl  
export ORACLE_BASE=/u01/app/oracle  
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1  
export LD_LIBRARY_PATH=$ORACLE_HOME/lib  
export PATH=$PATH:$ORACLE_HOME/bin
export NAME=`date -d now +%F`
$ORACLE_HOME/bin/rman target /  nocatalog  log=/datarman/rmanbak/dbfile_log/emoss2dbrmanarchback_$NAME.log<

--データベースレベル0のバックアップ・スクリプト(毎週3~土曜3時)
[oracle@localhost dbrman_scripts]$ chmod u+x emoss2dblev0.sh
[oracle@localhost dbrman_scripts]$ vi emoss2dblev0.sh
export ORACLE_SID=orcl  
export ORACLE_BASE=/u01/app/oracle  
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1  
export LD_LIBRARY_PATH=$ORACLE_HOME/lib  
export PATH=$PATH:$ORACLE_HOME/bin
export NAME=`date -d now +%F`
$ORACLE_HOME/bin/rman target /  nocatalog  log=/datarman/rmanbak/dbfile_log/emoss2dbrmanlevel0_$NAME.log<

計画タスク
[oracle@localhost dbrman_scripts]$ crontab -e
0  1  * * *    /datarman/rmanbak/dbrman_scripts/emoss2dbdel.sh
0  2  * * *    /datarman/rmanbak/dbrman_scripts/emoss2dbarch.sh
0  3  * * 3,6  /datarman/rmanbak/dbrman_scripts/emoss2dblev0.sh