1-oracle-rac-rman的数据备份脚本
概述:oracle11g-rac
1、数据备份文件有四:参数文件(spfile),控制文件(controlfile),数据文件(database ),归档日志(archivelog)
1、开启归档
rac集群开启归档 su - grid asmcmd mkdir -p +DATA/icdc_archive srvctl stop database -d icdc startup mount; alter system set log_archive_dest_1='LOCATION=+DATA/icdc_archive' scope=spfile; alter database archivelog; 重启Oracle实例 SQL> shutdown immediate; SQL> startup; 检查归档模式状态 SQL> archive log list
2、数据备份脚本
#rman全量备份
00 01 * * 0 cd /data/rmanback/ && nohup ./rman_bacp_level_0_12.sh >> /data/rmanback/rman.out 2>&1 &
[oracle@sjdb1 rmanback]$ cat rman_bacp_level_0_12.sh
######rman全备
for db in icdc
do
echo $db
touch /data/rmanback/$db
#导入环境变量
source ~/.bash_profile_$db
#备份存放目录
backdir=/data/rmanback/$db/level_0
DATE=`date +%F | sed 's/-//g'`
mkdir -p $backdir/$DATE/arch
mkdir -p $backdir/$DATE/control
mkdir -p $backdir/$DATE/datafile
mkdir -p $backdir/$DATE/spfile
mkdir -p $backdir/$DATE/log
rman log ''$backdir'/'$DATE'/log/db_rman0.log' append <<EOF
connect target /
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;
allocate channel c6 type disk;
allocate channel c7 type disk;
allocate channel c8 type disk;
backup incremental level 0 database format '$backdir/$DATE/datafile/datafile_%U.bak';
sql 'alter system archive log current';
backup archivelog all format '$backdir/$DATE/arch/arch_%U.log' delete all input;
backup spfile format = '$backdir/$DATE/spfile/spfile_%U_%T.bak';
backup current controlfile format '$backdir/$DATE/control/control_%U_%T.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
}
EOF
done
#rman增量备份 00 01 * * 1-6 cd /data/rmanback/ && nohup ./rman_bacp_level_1_12.sh >> /data/rmanback/rman.out 2>&1 & [oracle@sjdb1 rmanback]$ cat rman_bacp_level_1_12.sh #########rman增量 for db in icdc do echo $db #导入环境变量 source ~/.bash_profile_$db #备份存放目录 backdir=/data/rmanback/$db/level_1 DATE01=`date +%F | sed 's/-//g'` mkdir -p $backdir/$DATE01/arch mkdir -p $backdir/$DATE01/control mkdir -p $backdir/$DATE01/datafile mkdir -p $backdir/$DATE01/spfile mkdir -p $backdir/$DATE01/log DATE=`date +%F | sed 's/-//g'``date +%T | sed 's/://g'` rman log=''$backdir'/'$DATE01'/log/db_rman1_'$DATE'.log' append <<EOF connect target / run{ crosscheck backup; crosscheck archivelog all; delete noprompt expired backup; delete noprompt expired archivelog all; delete noprompt obsolete; allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; #差异 backup incremental level 1 database format '$backdir/$DATE01/datafile/data_level_1_%U_$DATE.bak'; #累积 #backup incremental level 1 cumulative database; sql 'alter system archive log current'; sql 'alter system archive log current'; backup archivelog all format '$backdir/$DATE01/arch/arch_%U_$DATE.log' delete all input; backup spfile format = '$backdir/$DATE01/spfile/spfile_%U_%T_$DATE.bak'; backup current controlfile format '$backdir/$DATE01/control/control_%U_%T_$DATE.bak'; release channel c1; release channel c2; release channel c3; } EOF done
数据恢复操作记录:点击
本文来自博客园,作者:!!雪莲花!!,转载请注明原文链接:https://www.cnblogs.com/zhj5418/p/18896859
浙公网安备 33010602011771号