RMAN备份方案
RMAN备份归档模式下损坏(丢失)多个数据文件,进行整个数据库的恢复
1、连接数据库,创建测试表并插入记录
SQL*Plus: Release 8.1.6.0.0 - Production on Tue May 6 13:46:32 2003 oracle培训 (c) Copyright 1999 Oracle Corporation. All rights reserved. SQL> connect internal/password as sysdba; Connected. SQL> create table test(a int); Table created SQL> insert into test values(1); 1 row inserted SQL> commit; Commit complete
2、备份
数据库
DOS下 C:>\ rman cmdfile=bakup.rcv msglog=backup.log; 以下是backup.log内容。 Recovery Manager: Release 8.1.6.0.0 - Production RMAN> # script:bakup.rcv 2> # creater:chenjiping 3> # date:5.8.2003 4> # desc:backup all database datafile in archive with rman 5> 6> #connect database 7> connect rcvcat rman/rman@back ; 8> connect target internal/virpure; 9> 10> #start backup database 11> run{ 12> allocate channel c1 type disk; 13> backup full tag 'dbfull' format 'd:\backup\full%u_%s_%p' database 14> include current controlfile; 15> sql 'alter system archive log current'; 16> release channel c1; 17> } 18> #end 19> RMAN-06008: connected to recovery catalog database RMAN-06005: connected to target database: TEST (DBID=1788174720) RMAN-03022: compiling command: allocate RMAN-03023: executing command: allocate RMAN-08030: allocated channel: c1 RMAN-08500: channel c1: sid=15 devtype=DISK RMAN-03022: compiling command: backup RMAN-03023: executing command: backup RMAN-08008: channel c1: starting full datafile backupset RMAN-08502: set_count=4 set_stamp=494074368 creation_time=15-MAY-03 RMAN-08010: channel c1: specifying datafile(s) in backupset RMAN-08522: input datafile fno=00002 name=D:\ORACLE\ORADATA\TEST\RBS01.DBF RMAN-08522: input datafile fno=00001 name=D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF RMAN-08011: including current controlfile in backupset RMAN-08522: input datafile fno=00005 name=D:\ORACLE\ORADATA\TEST\TOOLS01.DBF RMAN-08522: input datafile fno=00004 name=D:\ORACLE\ORADATA\TEST\TEMP01.DBF RMAN-08522: input datafile fno=00006 name=D:\ORACLE\ORADATA\TEST\INDX01.DBF RMAN-08522: input datafile fno=00003 name=D:\ORACLE\ORADATA\TEST\USER01.DBF RMAN-08013: channel c1: piece 1 created RMAN-08503: piece handle=D:\BACKUP\FULL04EN5UG0_4_1 comment=NONE RMAN-08525: backup set complete, elapsed time: 00:01:16 RMAN-03023: executing command: partial resync RMAN-08003: starting partial resync of recovery catalog RMAN-08005: partial resync complete RMAN-03022: compiling command: sql RMAN-06162: sql statement: alter system archive log current RMAN-03023: executing command: sql RMAN-03022: compiling command: release RMAN-03023: executing command: release RMAN-08031: released channel: c1 Recovery Manager complete.
到这里表示备份成功。
3、继续在测试表中插入记录
SQL> insert into test values(2); 1 row inserted SQL> commit; Commit complete SQL> select * from test; A --------------------------------------- 1 2 SQL> alter system switch logfile; System altered. SQL> alter system switch logfile; System altered.
4、关闭数据库,模拟丢失数据文件
SQL> shutdown immediate;
Database closed.
Database dismount