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级备份脚本(每周三和周六备份)
[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点备份  )
[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

你可能感兴趣的:(Oracle,备份恢复及数据迁移)