You are on page 1of 4

login as: dba1

dba1@192.168.0.11's password:
Last login: Mon Oct 26 19:49:49 2009 from 192.168.0.14
[dba1@oraserver ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 1 09:44:18 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> STARTUP
ORACLE instance started.
Total System Global Area 142606336 bytes
Fixed Size
1218172 bytes
Variable Size
88082820 bytes
Database Buffers
50331648 bytes
Redo Buffers
2973696 bytes
Database mounted.
Database opened.
SQL> SELECT NAME FROM V$DATABASE;
NAME
--------PROD1
SQL> ARCHIVE LOG LIST
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
/ora1/oradata/PROD/arch
Oldest online log sequence
8
Next log sequence to archive 9
Current log sequence
9
SQL> !
[dba1@oraserver ~]$ cd /ora1/oradata/PROD/
[dba1@oraserver PROD]$ ls
arch control1.ctl
rman
udump
bdump prod10gr2_block_change.fil sysaux01.dbf undotbs01.dbf
cbkp redo1a.log
system01.dbf users01.dbf
cdump redo2a.log
temp01.dbf
users02.dbf
[dba1@oraserver PROD]$ cd arch/
[dba1@oraserver arch]$ ls
1_700139386_10.arc 1_700139386_1.arc 1_700233891_1.arc 1_700236140_3.arc
1_700139386_11.arc 1_700139386_20.arc 1_700233891_2.arc 1_700236140_4.arc
1_700139386_12.arc 1_700139386_2.arc 1_700233891_3.arc 1_700236140_5.arc
1_700139386_13.arc 1_700139386_3.arc 1_700233891_4.arc 1_700236140_6.arc
1_700139386_14.arc 1_700139386_4.arc 1_700233891_5.arc 1_700236140_7.arc
1_700139386_15.arc 1_700139386_5.arc 1_700233891_6.arc 1_700236140_8.arc
1_700139386_16.arc 1_700139386_6.arc 1_700233891_7.arc 1_700236140_9.arc
1_700139386_17.arc 1_700139386_7.arc 1_700236140_10.arc
1_700139386_18.arc 1_700139386_8.arc 1_700236140_1.arc
1_700139386_19.arc 1_700139386_9.arc 1_700236140_2.arc
[dba1@oraserver ~]$ cd /ora1/oradata/PROD/
[dba1@oraserver PROD]$ ls
arch control1.ctl
rman
udump
bdump prod10gr2_block_change.fil sysaux01.dbf undotbs01.dbf
cbkp redo1a.log
system01.dbf users01.dbf
cdump redo2a.log
temp01.dbf
users02.dbf

[dba1@oraserver
[dba1@oraserver
[dba1@oraserver
[dba1@oraserver
exit

PROD]$
PROD]$
PROD]$
PROD]$

mkdir hbkp
cd /ora2/oradata/PROD/
mkdir hbkp
exit

SQL> spool hbkp.sql


SQL> select 'host cp -v '||name||' /ora1/oradata/PROD/hbkp' from v$datafile;
'HOSTCP-V'||NAME||'/ORA1/ORADATA/PROD/HBKP'
-------------------------------------------------------------------------------host cp -v /ora1/oradata/PROD/system01.dbf /ora1/oradata/PROD/hbkp
host cp -v /ora1/oradata/PROD/undotbs01.dbf /ora1/oradata/PROD/hbkp
host cp -v /ora1/oradata/PROD/sysaux01.dbf /ora1/oradata/PROD/hbkp
host cp -v /ora1/oradata/PROD/users01.dbf /ora1/oradata/PROD/hbkp
host cp -v /ora1/oradata/PROD/users02.dbf /ora1/oradata/PROD/hbkp
SQL> spool off
SQL> ed hbkp.sql -- edit the file and remove extra lines and retain only query o
utput
SQL> spool begin_backup.sql
SQL> select 'alter tablespace '||tablespace_name||' begin backup;' from dba_tabl
espaces where contents!='TEMPORARY';
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
------------------------------------------------------------alter tablespace SYSTEM begin backup;
alter tablespace UNDOTBS begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace USERS begin backup;
SQL> spool off
SQL> ed begin_backup.sql -- edit the file and remove extra lines and retain only
query output
SQL> spool end_backup.sql
SQL> select 'alter tablespace '||tablespace_name||' end backup;' from dba_tables
paces where contents!='TEMPORARY'
SQL> /
'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;'
----------------------------------------------------------alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS end backup;
alter tablespace SYSAUX end backup;
alter tablespace USERS end backup;
SQL> spool off
SQL> ed end_backup.sql -- edit the file and remove extra lines and retain only q
uery output
SQL> select * from v$backup; -- shows the scn of the last hot backup.
FILE#
---------1
2
3
4
5

STATUS
CHANGE# TIME
------------------ ---------- --------INACTIVE
1193200 01-NOV-09
INACTIVE
1193222 01-NOV-09
INACTIVE
1193183 01-NOV-09
INACTIVE
1193230 01-NOV-09
INACTIVE
1193132 01-NOV-09

SQL> @begin_backup.sql
Tablespace altered.
Tablespace altered.
Tablespace altered.
Tablespace altered.
SQL> select * from v$backup;
FILE#
---------1
2
3
4
5

STATUS
CHANGE# TIME
------------------ ---------- --------ACTIVE
2193269 01-NOV-09
ACTIVE
2193276 01-NOV-09
ACTIVE
2193283 01-NOV-09
ACTIVE
2193290 01-NOV-09
ACTIVE
2193290 01-NOV-09

SQL> @hbkp.sql
`/ora1/oradata/PROD/system01.dbf' -> `/ora1/oradata/PROD/hbkp/system01.dbf'
`/ora1/oradata/PROD/undotbs01.dbf' -> `/ora1/oradata/PROD/hbkp/undotbs01.dbf'
`/ora1/oradata/PROD/sysaux01.dbf' -> `/ora1/oradata/PROD/hbkp/sysaux01.dbf'
`/ora1/oradata/PROD/users01.dbf' -> `/ora1/oradata/PROD/hbkp/users01.dbf'
`/ora1/oradata/PROD/users02.dbf' -> `/ora1/oradata/PROD/hbkp/users02.dbf'
SQL> @end_backup.sql
Tablespace altered.
Tablespace altered.
Tablespace altered.
Tablespace altered.
SQL> select * from v$backup;
FILE#
---------1
2
3
4
5

STATUS
CHANGE# TIME
------------------ ---------- --------NOT ACTIVE
2193269 01-NOV-09
NOT ACTIVE
2193276 01-NOV-09
NOT ACTIVE
2193283 01-NOV-09
NOT ACTIVE
2193290 01-NOV-09
NOT ACTIVE
2193290 01-NOV-09

SQL> alter database backup controlfile to '/ora1/oradata/PROD/hbkp/control.ctl';


Database altered.
SQL> alter system archive log current;
System altered.
SQL> select * from v$backup;
FILE#
---------1
2
3
4
5
SQL>

STATUS
CHANGE# TIME
------------------ ---------- --------NOT ACTIVE
2193269 01-NOV-09
NOT ACTIVE
2193276 01-NOV-09
NOT ACTIVE
2193283 01-NOV-09
NOT ACTIVE
2193290 01-NOV-09
NOT ACTIVE
2193290 01-NOV-09

You might also like