根据自己对rman的理解,实践后可行的脚本,每月1日0级备份,每周末一级备份,每周除周末二级备份
[root@hdsb-db2 ~]# crontab -l -u oracle
59 2 1 * * /home/oracle/rman/rmbackup_level0.sh
59 23 * * 0 /home/oracle/rman/rmbackup_level1.sh
59 23 * * 1-6 /home/oracle/rman/rmbackup_level2.sh
rmbackup_level0.sh
#!/bin/bash
export ORACLE_BASE=/oracle/product
export ORACLE_HOME=/oracle/product/db_1
export ORACLE_SID=dlora2
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export TMP=/tmp
export TMPDIR=$TMP
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
nohup rman target / @/home/oracle/rman/rman_vivi_backupall_level0.rcv log=/home/oracle/rman/rman0.log &
rmbackup_level1.sh
nohup rman target / @/home/oracle/rman/rman_vivi_backupall_level1.rcv log=/home/oracle/rman/rman1.log &
rmbackup_level2.sh
nohup rman target / @/home/oracle/rman/rman_vivi_backupall_level2.rcv log=/home/oracle/rman/rman2.log &
rman_vivi_backupall_level0.rcv
configure controlfile autobackup format for device type disk to '/oracle/product/rmanback/ctl_%F';
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level=0 format '/oracle/product/rmanback/HD_%T_%s_%d' filesperset 5
database include current controlfile plus archivelog delete input;}
rman_vivi_backupall_level1.rcv
configure controlfile autobackup format for device type disk to '/oracle/product/rmanback/ctl_%F';
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level=1 format '/oracle/product/rmanback/HD_%T_%s_%d' filesperset 5
database include current controlfile plus archivelog delete input;}
rman_vivi_backupall_level2.rcv
configure controlfile autobackup format for device type disk to '/oracle/product/rmanback/ctl_%F';
DELETE OBSOLETE;
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level=2 format '/oracle/product/rmanback/HD_%T_%s_%d' filesperset 5
database include current controlfile plus archivelog delete input;}
备注:Rman的format格式中的%
%c 备份片的拷贝数
%d 数据库名称
%D 位于该月中的第几天 (DD)
%M 位于该年中的第几月 (MM)
%F 一个基于DBID唯一的名称,这个格式的形式为c-IIIIIIIIII-YYYYMMDD-QQ,其中IIIIIIIIII为该数据库的DBID,YYYYMMDD为
日期,QQ是一个1-256的序列
%n 数据库名称,向右填补到最大八个字符
%u 一个八个字符的名称代表备份集与创建时间
%p 该备份集中的备份片号,从1开始到创建的文件数
%U 一个唯一的文件名,代表%u_%p_%c
%s 备份集的号
%t 备份集时间戳
%T 年月日格式(YYYYMMDD)
恢复参考:
范例一:spfile文件及控制文件,所有数据文件的丢失
错误现象:startup
LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'
处理:
恢复spfile
connect target /
set dbid 1274918132#提前自己备份
startup nomount; #RMAN可从默认的Oracle配置参数中启动到nomount状态
restore spfile from '/db/bak/ctf/ORCL_ctf_bak_c-1274918132-20110506-02';#控制文件备份地址
shutdown immediate;
startup nomount;# LRM-00109错误消失
恢复控制文件
restore controlfile from '/db/bak/ctf/ORCL_ctf_bak_c-1274918132-20110506-02';#备份控制文件路径
alter database mount;#直接使用恢复的控制文件
恢复数据库
restore database;
recover database;
alter database open resetlogs;
————————————————
版权声明:本文为CSDN博主「回到未来望过去」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/viviliving/article/details/82861824