In this test I:
(1) Create a table called andrews_test1.
(2) Do an offline backup of the database using rman.
(3) Create a table called andrews_test2.
(4) Restore the database from the offline backup.
(5) Check that andrews_test1 is restored but andrews_test2 is not.
The test was run on Oracle 11.2. I created the database using dbca. To make it easy to demonstrate, I put the datafiles, redo logs and control files all in the same place. Here they are:
ANDREW01 /database/Andrew/ANDREW01 > ls -lt
total 2732896
-rw-r----- 1 oracle dba 9748480 Aug 22 15:24 control01.ctl
-rw-r----- 1 oracle dba 9748480 Aug 22 15:24 control02.ctl
-rw-r----- 1 oracle dba 52429312 Aug 22 15:23 redo02.log
-rw-r----- 1 oracle dba 5251072 Aug 22 15:23 users01.dbf
-rw-r----- 1 oracle dba 31465472 Aug 22 15:23 undotbs01.dbf
-rw-r----- 1 oracle dba 461381632 Aug 22 15:23 sysaux01.dbf
-rw-r----- 1 oracle dba 702554112 Aug 22 15:23 system01.dbf
-rw-r----- 1 oracle dba 52429312 Aug 22 15:23 redo03.log
-rw-r----- 1 oracle dba 52429312 Aug 22 15:23 redo01.log
-rw-r----- 1 oracle dba 20979712 Aug 22 12:53 temp01.dbf
drwxr-x--- 3 oracle dba 1024 Aug 22 12:20 backupset
drwxr-xr-x 2 oracle dba 1024 Aug 8 12:58 offline_backup
drwxr-x--- 2 oracle dba 80 Aug 8 11:48 archivelog
drwxr-x--- 2 oracle dba 80 Aug 7 15:33 onlinelog
ANDREW01 /database/Andrew/ANDREW01 >
I checked to see if the database was in ARCHIVELOG or NOARCHIVELOG mode:
SQL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
SQL>
Then
I created a test table and counted the number of rows in it. As the
backup has not been done yet, I expect this table to appear after the
restore:
SQL> create table andrews_test1
2 as select * from dba_tables;
Table created.
SQL> select count(*) from andrews_test1;
COUNT(*)
----------
2723
SQL>
I closed the database and mounted it:
ANDREW01 /database/Andrew/ANDREW01 > rman nocatalog target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Aug 22 15:28:36 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ANDREW01 (DBID=385736687)
using target database control file instead of recovery catalog
RMAN> shutdown
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 417669120 bytes
Fixed Size 2148672 bytes
Variable Size 255858368 bytes
Database Buffers 155189248 bytes
Redo Buffers 4472832 bytes
RMAN>
Then I checked that there were no backups, did a backup and checked that rman could see it:
ANDREW01 /database/Andrew/ANDREW01 > rman nocatalog target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Aug 22 15:52:36 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ANDREW01 (DBID=385736687, not open)
using target database control file instead of recovery catalog
RMAN> list backup;
specification does not match any backup in the repository
RMAN> backup database;
Starting backup at 22-AUG-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=292 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/database/Andrew/ANDREW01/system01.dbf
input datafile file number=00002 name=/database/Andrew/ANDREW01/sysaux01.dbf
input datafile file number=00003 name=/database/Andrew/ANDREW01/undotbs01.dbf
input datafile file number=00004 name=/database/Andrew/ANDREW01/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-AUG-12
channel ORA_DISK_1: finished piece 1 at 22-AUG-12
piece
handle=/database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_nnndf_TAG20120822T155255_839wl8dj_.bkp
tag=TAG20120822T155255 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 22-AUG-12
channel ORA_DISK_1: finished piece 1 at 22-AUG-12
piece
handle=/database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_ncnnf_TAG20120822T155255_839wmdo5_.bkp
tag=TAG20120822T155255 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-AUG-12
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 943.45M DISK 00:00:27 22-AUG-12
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20120822T155255
Piece Name: /database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_nnndf_TAG20120822T155255_839wl8dj_.bkp
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 947201 22-AUG-12 /database/Andrew/ANDREW01/system01.dbf
2 Full 947201 22-AUG-12 /database/Andrew/ANDREW01/sysaux01.dbf
3 Full 947201 22-AUG-12 /database/Andrew/ANDREW01/undotbs01.dbf
4 Full 947201 22-AUG-12 /database/Andrew/ANDREW01/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 9.33M DISK 00:00:02 22-AUG-12
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20120822T155255
Piece Name: /database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_ncnnf_TAG20120822T155255_839wmdo5_.bkp
Control File Included: Ckp SCN: 947201 Ckp time: 22-AUG-12
RMAN>
This is the backup at the UNIX level:
ANDREW01 /database/Andrew/ANDREW01/backupset/2012_08_22 > ls -l
total 1952304
-rw-r----- 1 oracle dba 9797632 Aug 22 15:53 o1_mf_ncnnf_TAG20120822T155255_839wmdo5_.bkp
-rw-r----- 1 oracle dba 989282304 Aug 22 15:53 o1_mf_nnndf_TAG20120822T155255_839wl8dj_.bkp
ANDREW01 /database/Andrew/ANDREW01/backupset/2012_08_22 >
I
opened the database (this is not shown), created another test table and
counted the number of rows in it. As the backup has now been done, I do
not expect this table to appear after the restore:
SQL> create table andrews_test2
2 as select * from dba_indexes;
Table created.
SQL> select count(*) from andrews_test2;
COUNT(*)
----------
4656
SQL>
I closed the database (this is not shown) then I deleted the database’s datafiles:
ANDREW01 /database/Andrew/ANDREW01 > ls -lt
total 2753392
-rw-r----- 1 oracle dba 9748480 Aug 22 16:31 control01.ctl
-rw-r----- 1 oracle dba 9748480 Aug 22 16:31 control02.ctl
-rw-r----- 1 oracle dba 5251072 Aug 22 16:31 users01.dbf
-rw-r----- 1 oracle dba 461381632 Aug 22 16:31 sysaux01.dbf
-rw-r----- 1 oracle dba 31465472 Aug 22 16:31 undotbs01.dbf
-rw-r----- 1 oracle dba 713039872 Aug 22 16:31 system01.dbf
-rw-r----- 1 oracle dba 52429312 Aug 22 16:31 redo02.log
-rw-r----- 1 oracle dba 52429312 Aug 22 16:28 redo03.log
-rw-r----- 1 oracle dba 52429312 Aug 22 16:28 redo01.log
-rw-r----- 1 oracle dba 20979712 Aug 22 15:27 temp01.dbf
drwxr-x--- 3 oracle dba 1024 Aug 22 12:20 backupset
drwxr-xr-x 2 oracle dba 1024 Aug 8 12:58 offline_backup
drwxr-x--- 2 oracle dba 80 Aug 8 11:48 archivelog
drwxr-x--- 2 oracle dba 80 Aug 7 15:33 onlinelog
ANDREW01 /database/Andrew/ANDREW01 > rm *dbf
ANDREW01 /database/Andrew/ANDREW01 > ls -lt
total 345632
-rw-r----- 1 oracle dba 9748480 Aug 22 16:31 control01.ctl
-rw-r----- 1 oracle dba 9748480 Aug 22 16:31 control02.ctl
-rw-r----- 1 oracle dba 52429312 Aug 22 16:31 redo02.log
-rw-r----- 1 oracle dba 52429312 Aug 22 16:28 redo03.log
-rw-r----- 1 oracle dba 52429312 Aug 22 16:28 redo01.log
drwxr-x--- 3 oracle dba 1024 Aug 22 12:20 backupset
drwxr-xr-x 2 oracle dba 1024 Aug 8 12:58 offline_backup
drwxr-x--- 2 oracle dba 80 Aug 8 11:48 archivelog
drwxr-x--- 2 oracle dba 80 Aug 7 15:33 onlinelog
ANDREW01 /database/Andrew/ANDREW01 >
I restored the database as follows:
ANDREW01 /database/Andrew/ANDREW01 > rman nocatalog target /
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Aug 23 14:53:25 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
Oracle instance started
Total System Global Area 417669120 bytes
Fixed Size 2148672 bytes
Variable Size 255858368 bytes
Database Buffers 155189248 bytes
Redo Buffers 4472832 bytes
RMAN> restore controlfile from '/database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_ncnnf_TAG20120822T155255_839wmdo5_.bkp';
Starting restore at 23-AUG-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=99 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/database/Andrew/ANDREW01/control01.ctl
output file name=/database/Andrew/ANDREW01/control02.ctl
Finished restore at 23-AUG-12
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database;
Starting restore at 23-AUG-12
Starting implicit crosscheck backup at 23-AUG-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=292 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 23-AUG-12
Starting implicit crosscheck copy at 23-AUG-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 23-AUG-12
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /database/Andrew/ANDREW01/offline_backup/sysaux01.dbf
File Name: /database/Andrew/ANDREW01/offline_backup/system01.dbf
File Name: /database/Andrew/ANDREW01/offline_backup/temp01.dbf
File Name: /database/Andrew/ANDREW01/offline_backup/undotbs01.dbf
File Name: /database/Andrew/ANDREW01/offline_backup/users01.dbf
File Name: /database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_ncnnf_TAG20120822T155255_839wmdo5_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /database/Andrew/ANDREW01/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /database/Andrew/ANDREW01/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /database/Andrew/ANDREW01/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /database/Andrew/ANDREW01/users01.dbf
channel
ORA_DISK_1: reading from backup piece
/database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_nnndf_TAG20120822T155255_839wl8dj_.bkp
channel
ORA_DISK_1: piece
handle=/database/Andrew/ANDREW01/backupset/2012_08_22/o1_mf_nnndf_TAG20120822T155255_839wl8dj_.bkp
tag=TAG20120822T155255
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 23-AUG-12
RMAN> alter database open resetlogs;
database opened
RMAN>
I checked that andrews_test1 had the same number of rows as before and that andrews_test2 had not been restored:
ANDREW01 /database/Andrew/ANDREW01 > sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 23 14:59:12 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count(*) from andrews_test1;
COUNT(*)
----------
2723
SQL> select count(*) from andrews_test2;
select count(*) from andrews_test2
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL>
No comments:
Post a Comment