C/C++教程

oracle rman 备份与还原

本文主要是介绍oracle rman 备份与还原,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

完备脚本

#!/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 rman 备份与还原的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!