ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

oracle rman 备份与还原

2022-01-31 09:59:11  阅读:188  来源: 互联网

标签:备份 ORACLE export allocate oracle release rman disk channel


完备脚本

#!/bin/bash

export ORACLE_SID=db3
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1

$ORACLE_HOME/bin/rman target / << EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
crosscheck archivelog all;

backup as compressed backupset database format '/dbbackup/full_dbbackup_%T_%d_%U';

sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '/dbbackup/Arch_%d_%T_%s.bak' archivelog all;

delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}
EOF

差异备份脚本

#!/bin/bash

export ORACLE_SID=sqmesdb3
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1

pscnt=`ps -ef | grep rman | grep -v grep | wc -l`
echo "archivebackupprocesscount:$pscnt"
if [ $pscnt -gt 0 ];then
   echo "`date`exitarchivelogbackup!"
   exit 0
else
   $ORACLE_HOME/bin/rman target / << EOF
   run{
#   backup as compressed backupset archivelog all format '/dbbackup/archivelog_backup_%T_%d_%U' not backed up 2 times;
   # backup as compressed backupset archivelog all format '/dbbackup/archivelog_backup_%T_%d_%U';
   delete noprompt archivelog all completed before 'sysdate-7';
   }
EOF
fi

异机还原脚本

catalog start with '/dbbackup/';  # 指定日志路径
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
RESTORE DATABASE ;
#recover database using backup controlfile until cancel;
recover database until time "to_date('2022-01-27 20:40:00','yyyy-mm-dd hh24:mi:ss')";
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

标签:备份,ORACLE,export,allocate,oracle,release,rman,disk,channel
来源: https://blog.csdn.net/hoffmannlin/article/details/122758262

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有