Oracle RMAN备份还原方案

前端之家收集整理的这篇文章主要介绍了Oracle RMAN备份还原方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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相关文章