I did this how-to with the purpose of you using it as a ” best practice” and having a regular backup of your Oracle Home in case you, or another guy on your team, accidentally remove part of or entire files and folders on it.
I will reproduce the steps on Compute instance in OCI; I hope that is not your case on a production database server, but nobody knows when shit happens, and you may need this procedure to recover and put your database online after an accident.
As you can see, my database is up and running in my Oracle 19c home.
The location of my ORACLE HOME is listed for this database on my file /etc/oratab
Now, let’s issue a backup of my oracle home, do this procedure with root user. You can backup OH online, no problem at all on the database side to issue this step.
[oracle@oracle-db-lab dbhome_1]$ tar -cf /home/oracle/dbhome19c_installed.tar . [oracle@oracle-db-lab dbhome_1]$ ls -ltrh /home/oracle/dbhome19c_installed.tar -rw-r--r--. 1 oracle oinstall 5.0G Jan 18 22:35 /home/oracle/dbhome19c_installed.tar [oracle@oracle-db-lab dbhome_1]$
I will remove all files on my Oracle Home to simulate the corruption or loss of the Oracle Home.
After removing the directory we will validate that it is not working
Now all utilities were gone!!
As root user again, let’s restore our backup from Oracle Home to the correct path using these commands below and let’s check the size of the folder:
[oracle@oracle-db-lab dbhome_1]$ tar -xf /home/oracle/dbhome19c_installed.tar .
Now all utilities were gone!!
As root user again, let’s restore our backup from Oracle Home to the correct path using these commands below and let’s check the size of the folder:
[oracle@oracle-db-lab dbhome_1]$ tar -xf /home/oracle/dbhome19c_installed.tar .
As you can see, it is the same size as the original one, 5 GB, which is good for us. To guarantee that everything is good, I will do a relink on Oracle binaries before I try to open my database again.
There are no errors on the relink file, so it means that we successfully restored our original Oracle home, and now we can start our database again.
I hope this article helps you restore the situation I described initially. I recommend you include a backup of your Oracle Home in your backup schedules. Otherwise, you will need to reinstall Oracle again and maybe patch all the patches you applied to your Oracle Home before the crash.
See you in the next article.
Disclaimer: “The postings on this site are my own and do not necessarily represent my current employer positions, strategies, or opinions. The information here was edited to be useful for general purpose, specific data, and identifications was removed to allow reaching a generic audience and to be useful.