1.数据库版本和rman参数【木有恢复目录,rman信息放在控制文件里面】

 

[oracle@localhost rman]$ sqlplus / as sysdba


SQL*Plus: Release 10.2.0.4.0 - Production on 星期五 7月 29 12:27:51 2011


Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.



连接到:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

 

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

 

 

SQL> exit

从 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

[oracle@localhost rman]$ rman target /


恢复管理器: Release 10.2.0.4.0 - Production on 星期五 7月 29 12:28:27 2011


Copyright (c) 1982, 2007, Oracle.  All rights reserved.


连接到目标数据库: ORCL (DBID=1283756176)


RMAN> show all;


使用目标数据库控制文件替代恢复目录

RMAN 配置参数为:

CONFIGURE RETENTION POLICY TO REDUNDANCY 2; 【保留策略为两份】

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 '/ora_db/rman/cf_%F_%T'; 【自动备份控制文件保存格式】

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 MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default

RMAN>

 

2.备份脚本
 
 
 

[oracle@localhost rman]$ more rman_new.sh

PATH=$PATH:$HOME/bin

export PATH

# added by oranavi
export ORACLE_BASE=/ora_db
export ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl
export NLS_LANG="Simplified Chinese_CHINA.ZHS16GBK"
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_DOC=$ORACLE_HOME/doc
CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/JRE
CLASSPATH=$CLASSPATH:$ORACLE_HOME/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/jdbc/lib/classes12.jar
CLASSPATH=$CLASSPATH:$ORACLE_HOME/jdbc/lib/nls_charset12.jar
export CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/jdbc/lib
export LD_LIBRARY_PATH

 
--【如上是本服务器的oracle用户环境变量参数,为oracle下.bash_profile的相应内容】
 
 
 
--【之前测试脚本,没用如上参数,crontab就是不执行……加上就自动执行了!】

#export BACK_DATE='date +%Y%m%d'
--【msglog的日期格式,未用上的,可以忽略或可以自己设定,全备日志在crontab里面有日志文件】

rman target / msglog=/ora_db/rman/rman_db_$BACK_DATE.log << EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system switch logfile';
backup database format '/ora_db/rman/full_db_%U_%T';
backup archivelog all delete all input format '/ora_db/rman/ARC_%U_%T';
release channel c1;
release channel c2;
}
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
report obsolete;
delete noprompt obsolete;
exit
EOF
[oracle@localhost rman]$

 
3.Oracle用户下crontab列表
 
 
 
[oracle@localhost rman]$ crontab -l
31 11 * * * /ora_db/rman/rman_new.sh >> /ora_db/rman/rman_new.log
--【前面时间按自己环境调】
 
4.备份完成后的文件列表
[oracle@localhost rman]$ ll

-rw-r----- 1 oracle oinstall   391638528 07-29 12:05 ARC_0tmilb7h_1_1_20110729
-rw-r----- 1 oracle oinstall   359939072 07-29 12:05 ARC_0umilb7h_1_1_20110729
-rw-r----- 1 oracle oinstall    20791808 07-29 12:05 ARC_0vmilb8a_1_1_20110729
-rw-r----- 1 oracle oinstall     8159232 07-29 12:05 cf_c-1283756176-20110729-00_20110729
-rw-r----- 1 oracle oinstall 48987914240 07-29 12:04 full_db_0rmil97n_1_1_20110729
-rw-r----- 1 oracle oinstall 42121199616 07-29 12:04 full_db_0smil97n_1_1_20110729
-rwxrwxrwx 1 oracle oinstall       12195 07-29 12:08 rman_new.log
-rwxrwxrwx 1 oracle oinstall        1269 07-29 11:24 rman_new.sh
-rwxrwxrwx 1 oracle oinstall          29 07-28 15:25 testdb.log
-rwxrwxrwx 1 oracle oinstall        3408 07-28 15:21 test.log
-rwxrwxrwx 1 oracle oinstall          46 07-28 15:08 test.rcv
-rwxrwxrwx 1 oracle oinstall          93 07-28 15:09 test.sh

5.备份日志就是如上列表的 rman_new.log 内容