数据库
首页 > 数据库> > 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,export,allocate,oracle,release,rman,disk,channel
来源: https://blog.csdn.net/hoffmannlin/article/details/122758262