Wednesday, September 22, 2010

Cold backup - roll forward archive logs - TESTCASE

this is a test case (ora 9.2.0.6 on solaris 8-64bit), hope it helps
----------------------------------------------------------------------------------
Enter user-name: / as sysdba

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

SQL> select name from v$controlfile union
2 select name from v$datafile;

NAME
/opt/oracle/product/ora92/dbatest/control01.ctl
/opt/oracle/product/ora92/dbatest/control02.ctl
/opt/oracle/product/ora92/dbatest/control03.ctl
/opt/oracle/product/ora92/dbatest/cwmlite01.dbf
/opt/oracle/product/ora92/dbatest/drsys01.dbf
/opt/oracle/product/ora92/dbatest/example01.dbf
/opt/oracle/product/ora92/dbatest/indx01.dbf
/opt/oracle/product/ora92/dbatest/odm01.dbf
/opt/oracle/product/ora92/dbatest/system01.dbf
/opt/oracle/product/ora92/dbatest/tools01.dbf
/opt/oracle/product/ora92/dbatest/undotbs01.dbf
/opt/oracle/product/ora92/dbatest/users01.dbf
/opt/oracle/product/ora92/dbatest/xdb01.dbf

13 rows selected.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
-----------------------------------------------------------------------------------------
now lets take a cold backup
$ cp *.dbf ./coldbackup/.
$ cp *.ctl ./coldbackup/.
$ cd coldbakcup
$ ls -ltr
total 1954528
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 drsys01.dbf
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 cwmlite01.dbf
-rw-r--r-- 1 oracle9 dba 155983872 Jun 1 12:26 example01.dbf
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 odm01.dbf
-rw-r--r-- 1 oracle9 dba 26222592 Jun 1 12:26 indx01.dbf
-rw-r--r-- 1 oracle9 dba 419438592 Jun 1 12:26 system01.dbf
-rw-r--r-- 1 oracle9 dba 42999808 Jun 1 12:26 temp01.dbf
-rw-r--r-- 1 oracle9 dba 10493952 Jun 1 12:26 tools01.dbf
-rw-r--r-- 1 oracle9 dba 209723392 Jun 1 12:26 undotbs01.dbf
-rw-r--r-- 1 oracle9 dba 26222592 Jun 1 12:26 users01.dbf
-rw-r--r-- 1 oracle9 dba 39985152 Jun 1 12:26 xdb01.dbf
-rw-r----- 1 oracle9 dba 2023424 Jun 1 12:27 control01.ctl
-rw-r----- 1 oracle9 dba 2023424 Jun 1 12:27 control03.ctl
-rw-r----- 1 oracle9 dba
---------------------------------------------------------------------------------
now lets create a table and insert some rows

SQL> startup
ORACLE instance started.

SQL> create table test (counter number(10));

Table created.

SQL> insert into test
2 select rownum from all_objects where rownum between &1 and &2
3 /
Enter value for 1: 1
Enter value for 2: 100
old 2: select rownum from all_objects where rownum between &1 and &2
new 2: select rownum from all_objects where rownum between 1 and 100

100 rows created.

SQL> commit;

Commit complete.
------------------------------------------------------------------------------------------------
SQL> alter system switch logfile;

System altered.
------------------------------------------------------------------------------------------------
SQL> insert into test select rownum from all_objects where rownum between &1 and &2
2 /
Enter value for 1: 1
Enter value for 2: 10
old 1: insert into test select rownum from all_objects where rownum between &1 and &2
new 1: insert into test select rownum from all_objects where rownum between 1 and 10

10 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from test;

COUNT(*)
110
--------------------------------------------------------------------------------------------
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.
-------------------------------------------------------------------------------------------------------------
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down. 2023424 Jun 1 12:27 control02.ctl
$
-----------------------------------------------------------------------------------------------------------

Now lets delete all data/controlfile/logfiles from current location and restore from cold backup

$ rm *.dbf *.log *.ctl

$ cd coldbackup
$ cp * ../.
$ ls -ltr
total 1954528
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 drsys01.dbf
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 cwmlite01.dbf
-rw-r--r-- 1 oracle9 dba 155983872 Jun 1 12:26 example01.dbf
-rw-r--r-- 1 oracle9 dba 20979712 Jun 1 12:26 odm01.dbf
-rw-r--r-- 1 oracle9 dba 26222592 Jun 1 12:26 indx01.dbf
-rw-r--r-- 1 oracle9 dba 419438592 Jun 1 12:26 system01.dbf
-rw-r--r-- 1 oracle9 dba 42999808 Jun 1 12:26 temp01.dbf
-rw-r--r-- 1 oracle9 dba 10493952 Jun 1 12:26 tools01.dbf
-rw-r--r-- 1 oracle9 dba 209723392 Jun 1 12:26 undotbs01.dbf
-rw-r--r-- 1 oracle9 dba 26222592 Jun 1 12:26 users01.dbf
-rw-r--r-- 1 oracle9 dba 39985152 Jun 1 12:26 xdb01.dbf
-rw-r----- 1 oracle9 dba 2023424 Jun 1 12:27 control01.ctl
-rw-r----- 1 oracle9 dba 2023424 Jun 1 12:27 control03.ctl
-rw-r----- 1 oracle9 dba 2023424 Jun 1 12:27 control02.ctl

-----------------------------------------------------------------------------------------------
$ sqlplus

SQL*Plus: Release 9.2.0.7.0 - Production on Fri Jun 1 12:32:47 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 320308936 bytes
Fixed Size 730824 bytes
Variable Size 285212672 bytes
Database Buffers 33554432 bytes
Redo Buffers 811008 bytes
Database mounted.

SQL> RESTORE DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;

SP2-0734: unknown command beginning "RESTORE DA..." - rest of line ignored.
SQL>
SQL> restore database using backup controlfile until cancel;
SP2-0734: unknown command beginning "restore da..." - rest of line ignored.
SQL>
SQL>
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 166115 generated at 06/01/2007 12:25:37 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/product/ora92/oradata/dbatest/archive/1_7.dbf
ORA-00280: change 166115 for thread 1 is in sequence #7

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 166232 generated at 06/01/2007 12:28:32 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/product/ora92/oradata/dbatest/archive/1_8.dbf
ORA-00280: change 166232 for thread 1 is in sequence #8
ORA-00278: log file '/opt/oracle/product/ora92/oradata/dbatest/archive/1_7.dbf'
no longer needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 166342 generated at 06/01/2007 12:29:35 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/product/ora92/oradata/dbatest/archive/1_9.dbf
ORA-00280: change 166342 for thread 1 is in sequence #9
ORA-00278: log file '/opt/oracle/product/ora92/oradata/dbatest/archive/1_8.dbf'
no longer needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 166408 generated at 06/01/2007 12:29:38 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/product/ora92/oradata/dbatest/archive/1_10.dbf
ORA-00280: change 166408 for thread 1 is in sequence #10
ORA-00278: log file '/opt/oracle/product/ora92/oradata/dbatest/archive/1_9.dbf'
no longer needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 166410 generated at 06/01/2007 12:29:39 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/product/ora92/oradata/dbatest/archive/1_11.dbf
ORA-00280: change 166410 for thread 1 is in sequence #11
ORA-00278: log file
'/opt/oracle/product/ora92/oradata/dbatest/archive/1_10.dbf' no longer needed
for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log
'/opt/oracle/product/ora92/oradata/dbatest/archive/1_11.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3

SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> SELECT COUNT(*) FROM TEST;

COUNT(*)
110

so i get backup my 110 rows