现在的位置: 首页 > 数据库 > 正文

Oracle RMAN 备份一例

2019年12月25日 数据库 ⁄ 共 3097字 ⁄ 字号 暂无评论
孙国栋广告

Oracle RMAN备份一例:

Solaris 10 + Oracle 11.2.0.3

Shell:csh,安装有bash,脚本调用bash

备份策略:周日0级备份,周一~周六1级备份,每6小时备份归档日志,每天清理历史文件夹.

--0级备份脚本:

#!/bin/bash
#db0 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
echo 'go on'
else
echo 'need mkdir'
mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target / log=/oradata1/backup/$foldername/full_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oradata1/backup/$foldername/controlfile%F';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup incremental level 0 tag 'db0' database format '/oradata1/backup/$foldername/db0_%d_%T_%s' include current controlfile;
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
RMAN_BACKUP
--1级备份脚本:

#!/bin/bash
#db1 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
echo 'go on'
else
echo 'need mkdir'
mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target / log=/oradata1/backup/$foldername/incr_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oradata1/backup/$foldername/controlfile%F';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup incremental level 1 tag 'db1' database format '/oradata1/backup/$foldername/db1_%d_%T_%s' include current controlfile;
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
RMAN_BACKUP
--归档备份

#!/bin/bash
#arch backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
echo 'go on'
else
echo 'need mkdir'
mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target / log=/oradata1/backup/$foldername/arch_LOG.log < /dev/null 2&>1#
0 1 * * 1-6 /oradata1/backupsh/db1_backup.rman > /dev/null 2&>1#
0 6,12,18 * * * /oradata1/backupsh/arch_backup.rman > /dev/null 2&>1#
0 3 * * * /oradata1/backupsh/del_old.sh > /dev/null 2&>1#

原文来自于:https://cloud.tencent.com/developer/article/1431629

给我留言

留言无头像?