SQL> show parameter control
SQL> alter system set control_file_record_keep_time=14 scope=both;
,开启之后在数据库备份或者数据文件(比如添加数据文件)有修改的时候都会自动备份控制文件和spfile文件。
configure controlfile autobackup on;
当数据库兼容性设置为大于等于10.0.0时,尽管在没有0级备份情况做1级的增量备份实际上是一个全备,但是这个全备也是1级的,不能用作1级积累增量备份的基础备份,这个是在设计备份策略的时候要注意的问题。
SQL>create tablespace ts_catalog datafile '/u01/app/Oracle/oradata/orcl/catalog_ts.dbf' size 1024M;
SQL>create user catalog identified by catalog default tablespace ts_atalog;
SQL>grant recovery_catalog_owner to catalog;
select * from dba_sys_privs where grantee='RECOVERY_CATALOG_OWNER';
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jul 15 12:03:16 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1248423599)
connected to recovery catalog database
recovery catalog created
如果此处报错:
ORACLE error from recovery catalog database: ORA-00955: name is already used by an existing object
可以用命令删除catalog,再创建:
recovery catalog owner is CATALOG
enter DROP CATALOG command again to confirm catalog removal
recovery catalog dropped
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
0级:相当于全备,不同的是0级可用于增量备份,全备不行。
1级:备份自上次0级备份以来的数据。
2级:备份自上次备份以来的数据。
脚本的增量备份策略: 周日0级备份,周四1级备份,其他2级备份。
#+--------------------------------------------------------------+
#|(C) 2011 LEISHIFEI All Right Reserved.
#+--------------------------------------------------------------+
#|File :incremental_hot_database_backup.sh
#|Source :$Source$
#|Description :Rman nocatalog full backup for Oracle 10g
#| linux or aix.
#+--------------------------------------------------------------+
#|Authors :leishifei
#+--------------------------------------------------------------+
#|Date :$Date$
#|Version :$Revision$
#+--------------------------------------------------------------+
#!/bin/ksh
export LANG=en_US
BACKUP_DATE=`date +%d`
RMAN_LOG_FILE=${0}.out
TODAY=`date`
USER=`id|cut -d "(" -f2|cut -d ")" -f1`
echo "-----------------$TODAY-------------------">$RMAN_LOG_FILE
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_HOME
RMAN=$ORACLE_HOME/bin/rman
export RMAN
ORACLE_SID=orcl
export ORACLE_SID
ORACLE_USER=oracle
export ORACLE_USER
echo "ORACLE_SID: $ORACLE_SID">>$RMAN_LOG_FILE
echo "ORACLE_HOME:$ORACLE_HOME">>$RMAN_LOG_FILE
echo "ORACLE_USER:$ORACLE_USER">>$RMAN_LOG_FILE
echo "------------------------------------------------">>$RMAN_LOG_FILE
echo "BACKUP DATABASE BEGIN......">>$RMAN_LOG_FILE
echo " ">>$RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
WEEK_DAILY=`date +%a`
case "$WEEK_DAILY" in
"Mon")
BAK_LEVEL=2
;;
"Tue")
BAK_LEVEL=2
;;
"Wed")
BAK_LEVEL=2
;;
"Thu")
BAK_LEVEL=1
;;
"Fri")
BAK_LEVEL=2
;;
"Sat")
BAK_LEVEL=2
;;
"Sun")
BAK_LEVEL=0
;;
"*")
BAK_LEVEL=error
esac
export BAK_LEVEL=$BAK_LEVEL
echo "Today is : $WEEK_DAILY incremental level= $BAK_LEVEL">>$RMAN_LOG_FILE
RUN_STR="
BAK_LEVEL=$BAK_LEVEL
export BAK_LEVEL
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
$RMAN TARGET sys/oracle CATALOG catalog/catalog@catalog1 msglog $RMAN_LOG_FILE append