一个完整的rman+flashback计划
一、备份时间计划:
星期
增量备份等级
日
Level 0
一
Level 2
二
Level 2
三
Level 1
四
Level 2
五
Level 2
六
Level 2
Rman配置:
RMAN>
show all;
using
target database control file instead of recovery catalog
RMAN
configuration parameters for database with db_unique_name TEST are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15
DAYS;
CONFIGURE
BACKUP OPTIMIZATION OFF; # default
CONFIGURE
DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE
TYPE DISK TO '/orarecover/backup/control/%F';
CONFIGURE
DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE
DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE
ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/orarecover/backup/tp_%u_%s_%p';
CONFIGURE
MAXSETSIZE TO UNLIMITED; # default
CONFIGURE
ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE
ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE
COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ;
# default
CONFIGURE
ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE
SNAPSHOT CONTROLFILE NAME TO '/db/oracle/product/11.2/dbs/snapcf_test.f'; #
default
三个等级的备份脚本:
[oracle@localhost
rman]$ cat baklevel0
run{
crosscheck backupset of archivelog all ;
delete
noprompt expired archivelog all;
backup
incremental level 0
tag
backup_inc0
database
include current
controlfile;
sql "alter system archive log
current"; 切换当前日志并且自动归档
backup format='/orarecover/backup/archivelog/%d_%s.arc' archivelog all
delete all input;
alter database backup controlfile to trace;
}
exit;
[oracle@localhost
~]$ cat /var/rman/baklevel1
run{
backup
incremental level 1
tag backup_inc1
database
include current
controlfile;
}
exit;
[oracle@localhost
~]$ cat /var/rman/baklevel2
run{
backup
incremental level 2
tag backup_inc2
database
include current
controlfile;
}
exit;
设置计划,超过七天的归档日志删除
[root@localhost
~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 2
* * * find/db/oracle/flash_recovery_area/TEST/archivelog-mtime +7 -exec rm -f {} \;
45 2 *
* 0 /home/oracle/script/rmanlevel0.sh
45 2 *
* 1 /home/oracle/script/rmanlevel2.sh
45 2 *
* 2 /home/oracle/script/rmanlevel2.sh
45 2 *
* 3 /home/oracle/script/rmanlevel1.sh
45 2 *
* 4 /home/oracle/script/rmanlevel2.sh
45 2 *
* 5 /home/oracle/script/rmanlevel2.sh
45 2 *
* 6 /home/oracle/script/rmanlevel2.sh
查看计划脚本:
[oracle@localhost
script]$ cat rmanlevel0.sh
export ORACLE_HOME='/db/oracle/product/11.2';
export ORACLE_SID='test';
/db/oracle/product/11.2/bin/rman
target /
cmdfile=/var/rman/baklevel0
log=/var/rman/archivelog/bakl0.log append
[oracle@localhost
script]$ cat rmanlevel1.sh
export ORACLE_HOME='/db/oracle/product/11.2';
export ORACLE_SID='test';
/db/oracle/product/11.2/bin/rman
target /
cmdfile=/var/rman/baklevel1
log=/var/rman/archivelog/bakl1.log append
[oracle@localhost
script]$ cat rmanlevel2.sh
export ORACLE_HOME='/db/oracle/product/11.2';
export ORACLE_SID='test';
/db/oracle/product/11.2/bin/rman
target /
cmdfile=/var/rman/baklevel2
log=/var/rman/archivelog/bakl2.log append
针对表的闪回数据归档
闪回数据归档是逻辑概念
闪回数据归档针对单个表或多个表的闪回支持,前提是闪回策略需要建立在表空间之上
让单个或多个闪回归档区对,单个或多个表空间的支持.
例如test1和test2我们需要他对一年的数据支持闪回,可以建立Flashback_archive_1闪回数据归档区对其支持
Test3只需要两天的数据闪回就可以,建立Flashback_archive_2闪回数据归档区对其支持。
详情可以参看,
所需备份文件位置:
控制文件/orarecover/backup/control/%F
rman备份位置:/orarecover/backup/tp_%u_%s_%p
归档日志:/db/oracle/flash_recovery_area/TEST/archivelog/