How to Backup and Restore ORACLE_HOME Binaries and Oracle Inventory Before Patching
Backing up your Oracle software environment — including the software binaries (ORACLE_HOME) and inventory metadata (oraInventory) — is a critical safety step before applying any patches to the database or operating system. This guide provides a clear, step-by-step process with real-world command outputs to help DBAs prepare for a reliable rollback if needed.
Why It Matters
- ORACLE_HOME contains Oracle executables, configuration files, and libraries.
- oraInventory maintains all Oracle installation details, necessary for patching and upgrades.
⚠️ Without a proper backup, any corruption or failed patch may require a full reinstallation of Oracle software.
Backup Preparation (Optional but Recommended)
🧯 1. Stop the Database (Recommended for Clean Backups)
$ ps -ef | grep pmon
oracle 24531 1 0 10:12 ? 00:00:00 ora_pmon_MYDB
oracle 24578 24490 0 10:13 pts/0 00:00:00 grep pmon
$ sqlplus / as sysdba
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
🔌 2. Stop the Listener (Optional but Advised)
$ ps -ef | grep tns
oracle 24641 1 0 10:15 ? 00:00:00 /u01/app/oracle/product/19.0.0/dbhome_1/bin/tnslsnr LISTENER
oracle 24678 24490 0 10:16 pts/0 00:00:00 grep tns
$ lsnrctl stop LISTENER
LSNRCTL for Linux: Version 19.0.0.0.0 - Production
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521)))
The command completed successfully
Creating Backups of Oracle Inventory and ORACLE_HOME
📦 3. Back Up Oracle Inventory
First, identify the location:
$ cat /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=dba
Then perform the backup:
$ cd /u01/app/
$ tar -pczvf /u02/oracle/backup/oraInventory_bkup.tar.gz oraInventory
oraInventory/
oraInventory/ContentsXML/
oraInventory/ContentsXML/inventory.xml
... (more files)
📁 Output Example:
$ ls -lh /u02/oracle/backup/
-rw-r--r-- 1 oracle dba 5.2M May 27 11:10 oraInventory_bkup.tar.gz
🏗️ 4. Back Up ORACLE_HOME Directory
Navigate to your Oracle installation path:
$ cd /u01/app/oracle/product
$ ls
19.0.0
Backup using tar
with compression and background execution:
$ nohup tar -pczvf /u02/oracle/backup/oracle_home_bkup.tar.gz 19.0.0 &
[1] 27792
nohup: ignoring input and redirecting stderr to stdout
Check the process:
$ jobs -l
[1]+ 27792 Running tar -pczvf /u02/oracle/backup/oracle_home_bkup.tar.gz 19.0.0 &
📁 Verify Output:
$ ls -lh /u02/oracle/backup/
-rw-r--r-- 1 oracle dba 3.2G May 27 11:18 oracle_home_bkup.tar.gz
Restoring Oracle Inventory and ORACLE_HOME
🔒 1. Shut Down the Database (Mandatory)
$ sqlplus / as sysdba
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
⛔ 2. Stop the Listener (Mandatory)
$ lsnrctl stop LISTENER
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521)))
The command completed successfully
🔁 3. Restore Oracle Inventory
Navigate to the base path:
$ cd /u01/app/
$ mv oraInventory oraInventory_old
$ tar -pxzvf /u02/oracle/backup/oraInventory_bkup.tar.gz
oraInventory/
oraInventory/ContentsXML/
...
🔄 4. Restore ORACLE_HOME
$ cd /u01/app/oracle/product
$ mv 19.0.0 19.0.0_old
$ tar -pxzvf /u02/oracle/backup/oracle_home_bkup.tar.gz
✅ Reset Ownership and Permissions (if needed):
$ chown -R oracle:dba 19.0.0
$ chmod -R 755 19.0.0
Helpful Notes and Final Advice
- Always confirm that the backup file is complete (check size and content).
- Consider backing up your oratab, .bash_profile, and environment variables too.
- Automate this backup with a script during your patch preparation window.
✅ Summary Checklist
Task | Status |
---|---|
Stop DB & Listener (Optional/Recommended) | ✅ |
Backup Oracle Inventory | ✅ |
Backup ORACLE_HOME | ✅ |
Restore steps validated | ✅ |