Monday, October 6, 2014

Backing Up and Restoring Oracle dbf

I had a brief excursion into installing Oracle and playing around with dbf files and figured to understand how to move the actual dbf file as a backup of the database and then restore it in a completely new installation.  These are notes I made using default parameters on Oracle and I'm not crazy enough to go into detail on what the hundreds of customized Oracle installs are available out there.

An important step before copying is to shutdown your Oracle instance and database.  So use your sysdba privileges and shut it down.  Then, basically, I copied the entire oradata folder from my ORACLE_BASE path into an external hard drive.  Along with that, I also copied the flash_recovery_area which contained the RMAN information as well as the revision of the database.  NOTE: the database from oradata must match the control.ctl file from flash_recovery_area.  If you startup the database again, the ctl file will be different and the backup won't work.

After reinstalling Oracle, I moved the oradata and flash_recovery_area from the fresh install into another folder (as precaution) and copied over the ones from my hard drive.  Then, I did:

SQL> startup mount;
SQL> recover database until cancel;
SQL> alter databse open resetlogs;

Then you can log into SQL*Plus and verify that the data is intact.  Afterwards, shut the database down.  This seems to take a long while to do but it will finish eventually.

No comments: