第5章 Oracle增量备份(包括datafile,controfile,archivelog)
脚本/tmp/tsm/rman/incre.sh
rq=`date +"%Y.%m.%d_%H.%M.%S"`
su - oracle -c /tmp/tsm/rman/rman.incre.sh >/tmp/tsm/log/rman.incre.$rq 2>&1
脚本/tmp/tsm/rman/rman.incre.sh
export ORACLE_SID=aml
rman target / rcvcat rman/rman@catalog / << EOF_RMAN
run{
allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t4 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t5 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t6 type 'sbt_tape' parms '
backup incremental level 1 tag '%d_full_%s_%p' filesperset 5 database diskratio=0 include current controlfile;
sql 'alter system archive log current';
backup format 'arch%t_%s_%p' diskratio=0 archivelog all delete input;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
}
EOF_RMAN
## delete OLD backups
export ORACLE_SID=aml
rman target / rcvcat rman/rman@catalog << EOF_RMAN
allocate channel for maintenance type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
crosscheck backup;
crosscheck archivelog all;
report obsolete;
delete noprompt obsolete recovery window of 90 days;
delete noprompt expired backup;
release channel;
EOF_RMAN
4.3.4、oracle备份验证
select output from v$rman_output order by stamp;
rman target / rcvcat rman/rman@catalog
list backup of tablespace users;
list backup of datafile 3;
list backup of database;----列出已备份的数据库的数据文件
list backup of controfile;----列出已备份的数据库的控制文件
list backup of archivelog all;--列出已备份的数据库的归档日志
list backup by file;
list recoverable backup of database;
list expired backup;
restore database preview;
4.3.5、oracle恢复测试
$>sqlplus /nolog
SQL> conn /as sysdba;
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1.7180E+10 bytes
Fixed Size 2114176 bytes
Variable Size 838864256 bytes
Database Buffers 1.6307E+10 bytes
Redo Buffers 31436800 bytes
Database mounted
rman target /
RMAN>
run {
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore controlfile from 'c-265712778-20090113-0a';
alter database mount;
}
allocated channel: t1
channel t1: sid=315 devtype=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.4.1.0
Starting restore at 2009-01-13 17:13:15
channel t2: skipped, autobackup already found
channel t3: skipped, autobackup already found
channel t4: skipped, autobackup already found
channel t5: skipped, autobackup already found
channel t6: skipped, autobackup already found
channel t7: skipped, autobackup already found
channel t8: skipped, autobackup already found
channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:17
output filename=+DG_ASAML/asaml/controlfile/current.256.674845095
output filename=+DG_ASAML_ARCH/asaml/controlfile/current.256.674845095
Finished restore at 2009-01-13 17:13:33
database mounted
released channel: t1
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
418 419 ASAML 1328686371 CURRENT 1 2008-12-30 16:58:11
RMAN>
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t4 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t5 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
set until time "to_date('Jan 13 2009 17:56:42','Mon DD YYYY HH24:MI:SS')";
restore database;
recover database;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
alter database open resetlogs;
}
allocated channel: t1
channel t1: sid=315 devtype=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.4.1.0
allocated channel: t2
channel t2: sid=314 devtype=SBT_TAPE
channel t2: Data Protection for Oracle: version 5.4.1.0
allocated channel: t3
channel t3: sid=313 devtype=SBT_TAPE
channel t3: Data Protection for Oracle: version 5.4.1.0
allocated channel: t4
channel t4: sid=312 devtype=SBT_TAPE
channel t4: Data Protection for Oracle: version 5.4.1.0
allocated channel: t5
channel t5: sid=311 devtype=SBT_TAPE
channel t5: Data Protection for Oracle: version 5.4.1.0
executing command: SET until clause
Starting restore at 2009-01-13 17:15:36
Starting implicit crosscheck backup at 2009-01-13 17:15:36
Crosschecked 39 objects
Finished implicit crosscheck backup at 2009-01-13 17:15:39
Starting implicit crosscheck copy at 2009-01-13 17:15:39
Finished implicit crosscheck copy at 2009-01-13 17:15:40
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +dg_asaml_arch/ASAML/AUTOBACKUP/2009_01_13/s_676052060.415.676052061
skipping datafile 13; already restored to file +DG_ASAML/asaml/datafile/mas_data.339.675595887
a_trade.370.675683005
skipping datafile 18; already restored to file +DG_ASAML/asaml/datafile/ts_a_xml.373.675683197
篇幅限制省略部分输出结果
................................................................................................................................................
skipping datafile 38; already restored to file +DG_ASAML/asaml/datafile/ts_a_trade_idx.400.675975405
channel t1: starting datafile backupset restore
channel t1: specifying datafile(s) to restore from backup set
restoring datafile 00043 to +DG_ASAML/asaml/datafile/testtsm.405.676030781
channel t1: reading from backup piece dbfull_676048210_51_1
channel t1: restored backup piece 1
piece handle=dbfull_676048210_51_1 tag=DBFULL
channel t1: restore complete, elapsed time: 00:03:36
Finished restore at 2009-01-13 17:19:27
Starting recover at 2009-01-13 17:19:29
starting media recovery
archive log thread 1 sequence 772 is already on disk as file +DG_ASAML/asaml/onlinelog/group_1.257.674845097
archive log thread 1 sequence 773 is already on disk as file +DG_ASAML/asaml/onlinelog/group_2.258.674845103
archive log thread 1 sequence 774 is already on disk as file +DG_ASAML/asaml/onlinelog/group_3.259.674845107
archive log filename=+DG_ASAML/asaml/onlinelog/group_1.257.674845097 thread=1 sequence=772
archive log filename=+DG_ASAML/asaml/onlinelog/group_2.258.674845103 thread=1 sequence=773
archive log filename=+DG_ASAML/asaml/onlinelog/group_3.259.674845107 thread=1 sequence=774
media recovery complete, elapsed time: 00:00:01
Finished recover at 2009-01-13 17:19:38
released channel: t1
released channel: t2
released channel: t3
released channel: t4
released channel: t5
database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> quit;
Recovery Manager complete.
asdb1:/app/oracle$>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jan 13 17:21:22 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn /as sysdba;
Connected.
SQL> select * from testtsm1;
select * from testtsm1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from SYSTEM.TESTTSM1;
TEST1 TEST2
-------------------------------- --------------------------------
TEST3 TEST4
-------------------------------- --------------------------------
TEST5
--------------------------------
1 2
3 4
5
SQL>