Skip to content
Home » Oracle » How to Restore Oracle Home

How to Restore Oracle Home

Suppose you have already known how to backup Oracle home and have at least one backup file, you can restore it whenever you need it.

Restore Oracle Home

Please make sure all Oracle service are stop before doing it.

First of all, we change PWD to the upper level of ORACLE_HOME by tailing double dots.

[root@test ~]# export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
[root@test ~]# cd $ORACLE_HOME/..
[root@test 19.3.0]# pwd

In this post, we introduce 3 ways to restore Oracle home.

  1. GNU tar Command
  2. UNIX tar Command
  3. unzip Command

GNU tar Command

Please make sure the filename of the backup file.

[root@test 19.3.0]# ll /backup/homes/*.tar.gz
-rw-r--r-- 1 root root 3952582998 Jun 20 21:55 /backup/homes/DB_HOME_20220620.tar.gz

In Linux, we usually use GNU tar command to backup Oracle homes.

[root@test 19.3.0]# tar -zxvf /backup/homes/DB_HOME_20220620.tar.gz > /backup/homes/DB_HOME_`date +%Y%m%d`_tar_restore.log
[root@test 19.3.0]# echo $?

Let's see the flags we used.

  • -z: uses gzip to process the compression and decompression.
  • -x: extracts from an archive file.
  • -v: outputs the result verbosely.
  • -f: file is the archive.

For extract mode, option -z is unnecessary if the tar archive was filtered and compressed by gzip (*.tar.gz).

Files will be uncompressed to the current directory.

[root@test 19.3.0]# ll
total 4
drwxr-xr-x 74 oracle oinstall 4096 Dec 16  2020 dbhome_1
[root@test 19.3.0]# ll dbhome_1/bin/oracle
-rwsr-s--x 1 oracle oinstall 443586008 Dec 16  2020 dbhome_1/bin/oracle

As we can see, not only ownership, permission and timestamp are preserved, but also symbolic links, setuid and setgid are all correctly restored.

UNIX tar Command

Just like we said, Unix tar command, it does not have -z flag to filter and decompress archive. In such case, it needs to cooperate with gunzip to explicitly decompress the file (*.tar.gz).

As usual, we switch PWD to the upper level of ORACLE_HOME, then issue the command.

[root@test 19.3.0]# gunzip < /backup/homes/DB_HOME_20220620.tar.gz | tar xvf -

It's the same result as GNU tar does.

unzip Command

If you already have a zip backup of Oracle home, you can use unzip to restore Oracle software.

[root@test 19.3.0]# ll /backup/homes/*.zip
-rw-r--r-- 1 root root 3532295017 Jun 20 22:07 /backup/homes/

Please make sure you are at the upper level of Oracle home.

[root@test 19.3.0]# /usr/bin/unzip -oXK /backup/homes/ > /backup/homes/DB_HOME_`date +%Y%m%d`_zip_restore.log
[root@test 19.3.0]# echo $?

Let's see the flags we used.

  • -o: overwrites any existing file without prompting.
  • -X: restores ownership and permissions.
  • -K: keeps setuid/setgid/tacky permissions.

Theoretically, there's no difference on unzip results between Linux and Unix. However, SELinux dot permission may not be preserved for Linux systems.

Leave a Reply

Your email address will not be published. Required fields are marked *