码迷,mamicode.com
首页 > 数据库 > 详细

Oracle RMAN备份还原方案

时间:2018-02-02 18:34:30      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:locate   amp   目录   disk   关闭   etl   tab   open   ora   

1、修改rman配置,能够恢复到7天内的任一时间点
su - oracle
rman target /
configure retention policy to recovery window of 7 days;
show all;

2、创建备份数据库和归档日志rman脚本online_database_archivelog.rman
#创建备份目录
mkdir -pv /backup/oraclebk/database
mkdir -pv /backup/oraclebk/archivelog
chown -R oracle.oinstall
su - oracle
mkdir scripts
cd scripts
vim online_database_archivelog.rman
#rman脚本内容
run {
allocate channel t1 type disk;
allocate channel t2 type disk;
backup as compressed backupset database format ‘/backup/oraclebk/database/database.%T.%U.rman‘;
backup as compressed backupset archivelog all delete all input format ‘/backup/oraclebk/archivelog/archivelog.%T.%U.rman‘;
}
delete noprompt obsolete;
#delete noprompt obsolete; 删除无效或过期的备份集

3、创建备份shell脚本
su - oracle
mkdir scripts
cd scripts
vim rman_backup.sh
#shell脚本内容
#!/bin/bash
source ~/.bash_profile
rman target / @/home/oracle/scripts/online_database_archivelog.rman > /home/oracle/scripts/backup.log

4、添加定时任务每天04:00备份
su - oracle
crontab -e
00 04 * sh /home/oracle/scripts/rman_backup.sh >/dev/null 2>&1

5、执行基于时间点不完全恢复(要求归档日志和重做日志完整,RAC环境需要将另一实例关闭)
run {
shutdown immediate;
startup mount;
set until time = "to_date(‘02-02-18 16:20:00‘,‘dd-mm-yy hh24:mi:ss‘)";
restore database;
recover database;
alter database open resetlogs;
}

Oracle RMAN备份还原方案

标签:locate   amp   目录   disk   关闭   etl   tab   open   ora   

原文地址:http://blog.51cto.com/linux10000/2068231

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!