189 8069 5689

oracle备份策略

RMAN>  CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN>  CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
启用控制文件自动备份及备份存放位置配置
RMAN> configure controlfile autobackup on;
查看配置信息
RMAN> show all;

目前成都创新互联已为千余家的企业提供了网站建设、域名、虚拟主机网站托管运营、企业网站设计、图们网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。


-------------------------------------------------
--创建文件夹
$mkdir /home/oracle/backup
mkdir /home/oracle/backup/script
mkdir /home/oracle/backup/log
mkdir /home/oracle/backup/export

--备份目的地
mkdir /home/oracle/rman_backup

创建备份表空间

create tablespace rman_tbs datafile '/u01/app/oracle/oradata/orcl11g/rman_tbs01.dbf'
size 1024M autoextend on next 50M maxsize 10240M
extent management local segment space management auto;

创建备份用户
create user rman identified by rman default tablespace rman_tbs temporary tablespace temp;


     grant connect,resource ,recovery_catalog_owner to rman;
SQL> grant unlimited tablespace to rman;
SQL> grant sysdba to rman;

 

rman catalog rman/rman
create catalog tablespace rman_tbs;
connect target sys/Oracle123@orcl11g
register database;
report schema;


-------------------------------------------------------

--倒出RMAN用户数据脚本exp_rman.par (即备份catalog库)


userid=rman/rman
file=/home/oracle/backup/export/rman.dmp
log=/home/oracle/backup/log/rman.log


-- 倒出RMAN数据SHELL脚本exp_rman.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
exp parfile=exp_rman.par

--------------

---零级备份RMAN脚本level0_backup.rcv
connect catalog rman/rman
connect target sys/Oracle123@orcl11g
run { 
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 0 database format '/home/oracle/rman_backup/level0_%d_%s_%p_%u.bak'
tag='level 0' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/arc_%d_%s_%p_%u.bak' ;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'sysdate-15';
resync catalog;

--零级备份SHELL脚本的level0_backup.sh
#!/bin/bash
backtime=`date +"%y%m%d%H"`
#cd $HOME
. /home/oracle/.bash_profile
cd $HOME/backup/script
rman cmdfile=level0_backup.rcv msglog=$HOME/backup/log/level0_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh

 

一级差异增量备份RMAN脚本 level1_backup.rcv
connect catalog rman/rman
connect target sys/Oracle123@orcl11g
run {
allocate channel d1 type disk;
backup incremental level 1 format '/home/oracle/rman_backup/level1_%d_%s_%p_%u.bak' tag = 'level 1'cumulative database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' ;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'sysdate-15';
resync catalog;

--一级差异增量备份SHELL脚本level1_backup.sh

#!/bin/bash
backtime=`date +"%y%m%d%H"`
#cd $HOME
. /home/oracle/.bash_profile
cd /home/oracle/backup/script
rman cmdfile=level1_backup.rcv msglog=$HOME/backup/log/level1_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh


linux下定时执行备份脚本

crontab -e -u oracle
SHELL=/bin/bash --以下脚本在bash下执行
MAILTO=oracle --执行日志以邮件形式邮给oracle用户,可以/var/spool/mail/oracle下查收
5 12 * * 1 nohup /home/oracle/backup/script/level0_backup.sh >/home/oracle/backup/cron.log 2>&1 &
5 12 * * 3 /home/oracle/backup/script/level1_backup.sh
5 12 * * 5 /home/oracle/backup/script/level1_backup.sh

 

一周差异备份策略:
备份目标库和catalog库
周一0级全备,周三周五为1级。
每天12点5分开始备份

 

 

 

 

 

 


本文名称:oracle备份策略
网页网址:http://cdxtjz.cn/article/gjsjig.html

其他资讯