I logged into an Oracle 12.1 database and ran the ALTER DATABASE BEGIN BACKUP command. This told Oracle I was about to start a hot backup:
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 26 10:08:51 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter database begin backup
2 /
Database altered.
SQL>
I copied one of the database’s datafiles somewhere safe:
C:\app\Administrator\oradata\ORCL1\DATAFILE>copy O1_MF_USERS_BDGW2LNZ_.DBF z:\data\oracle_backup
1 file(s) copied.
C:\app\Administrator\oradata\ORCL1\DATAFILE>
Then I used the ALTER DATABASE END BACKUP command to tell Oracle the hot backup was finished and closed the database:
SQL> alter database end backup;
Database altered.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
I deleted the datafile I had backed up:
C:\app\Administrator\oradata\ORCL1\DATAFILE>del O1_MF_USERS_BDGW2LNZ_.DBF
C:\app\Administrator\oradata\ORCL1\DATAFILE>
Then I restored it from the backup which I had made earlier:
Z:\Data\Oracle_Backup>copy O1_MF_USERS_BDGW2LNZ_.DBF C:\app\Administrator\oradata\ORCL1\DATAFILE
1 file(s) copied.
Z:\Data\Oracle_Backup>
I mounted the database:
Z:\Data\Oracle_Backup>sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Mar 18 15:50:55 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1720328192 bytes
Fixed Size 2403496 bytes
Variable Size 1023411032 bytes
Database Buffers 687865856 bytes
Redo Buffers 6647808 bytes
Database mounted.
SQL>
I read in some Oracle documentation that if you added the word TEST after a RECOVER
command, you could test the recovery you were about to attempt. I
decided to try it out but the messages it produced did not seem to tell
me whether the recovery would succeed or fail:
SQL> recover database test
ORA-10574: Test recovery did not corrupt any data block
ORA-10573: Test recovery tested redo from change 11524259 to 11525796
ORA-10572: Test recovery canceled due to errors
ORA-10585: Test recovery can not apply redo that may modify control file
SQL>
I decided to give it a try anyway and it worked without problem:
SQL> recover database
Media recovery complete.
SQL> alter database open
2 /
Database altered.
SQL>
No comments:
Post a Comment