Oracle RMAN

* refer to https://www.cnblogs.com/xibuhaohao/p/9956716.html Oracle数据库备份策略:全备与增量备份

* https://www.jianshu.com/p/27d5a591fc5f   Oracle 11g R2 Rman备份与恢复

* http://blog.itpub.net/29438041/viewspace-2134052/  OR  https://blog.csdn.net/zq9017197/article/details/6873490?locationNum=5&fps=1 通过RMAN备份恢复数据库到其他服务器 恢复整个数据库比如到其它

* https://www.jianshu.com/p/c9580fd97295?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation 命令详细解释

* Reference:

 

crontab -l
# archive backup
#01 4,12,20 * * * /oracle/scripts/rman_archive_backup.sh >/dev/null 2>&1

# full backup
#01 2 * * * //oracle/scripts/rman_full_backup.sh >/dev/null 2>&1

===========================================================
full_backup.rma
===========================================================
run
{
allocate channel c2 type disk;
BACKUP
    format '/Backup/oracle/rman/full_%d_%t_%s_%p'
    (DATABASE INCLUDE CURRENT CONTROLFILE);
release channel c2;
}


run
{
allocate channel c2 type disk;
backup current controlfile format '/Backup/oracle/rman/ctl_%d_%t_%s_%p';
release channel c2;
}


run
{
allocate channel c2 type disk;
crosscheck backup;
crosscheck copy;
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt  expired backup;
delete noprompt  expired archivelog all;
release channel c2;
}

===========================================================
archive_backup.rma
===========================================================

{
allocate channel t2 type disk;
sql 'alter system archive log current';
sql 'alter system archive log current';
backup format '/Backup/oracle/rman/%d_arch_%t_%s_%p' archivelog all delete input;
release channel t2;
}



run
{
allocate channel c2 type disk;
backup current controlfile format '/Backup/oracle/rman/ctl_%d_%t_%s_%p';
release channel c2;
}

===========================================================
rman_full_backup.sh
===========================================================
#!/bin/sh

#/home/oracle/scripts/rman_full_backup.sh
#backup full database shell script
#run by oracle  user

log_dir=/Backup/oracle/log
full_log=$log_dir/full_latest.log
rman_log=$log_dir/full_rman.log
all_log=$log_dir/full_all.log


. /home/oracle/.bash_profile
cd /home/oracle/scripts
echo "***************************************************************" > $full_log
echo "             Oracle Database Full Backup Begin...... " >> $full_log
date +"               %Y-%m-%d %H:%M:%S" >> $full_log

rman target / nocatalog  @full_backup.rma log=$rman_log

cat $rman_log >> $full_log
echo "              Oracle Database Full Backup  End  " >> $full_log
date +"               %Y-%m-%d %H:%M:%S"  >> $full_log
echo "****************************************************************" >> $full_log


echo "****************************************************************" >> $full_log
cat $full_log >> $all_log


===========================================================
rman_archive_backup.sh
===========================================================
#backup archivelog shell script
#run by oracle user

log_dir=/Backup/oracle/log
archive_log=$log_dir/archive_latest.log
rman_log=$log_dir/archive_rman.log
all_log=$log_dir/archive_all.log

. /home/oracle/.bash_profile
cd /home/oracle/scripts
echo "***************************************************************"  > $archive_log
echo "              Oracle Database Archivelog Backup Begin...... " >> $archive_log
date +"               %Y-%m-%d %H:%M:%S "  >> $archive_log

rman target / nocatalog @archive_backup.rma log=$rman_log

cat $rman_log >> $archive_log
echo "              Oracle Database Archivelog Backup  End   " >> $archive_log
date +"               %Y-%m-%d %H:%M:%S"  >> $archive_log
echo "**************************************************************" >> $archive_log

echo "****************************************************************" >> $archive_log
cat $archive_log >> $all_log

 

posted @ 2020-06-22 22:44  tang88seng  阅读(174)  评论(0编辑  收藏  举报