As a standard practice, DBAs often need to take backups of the ORACLE_HOME, GRID_HOME, or Application tier before applying patches.
This precaution ensures that in the event of a patch failure, we can easily roll back the changes.
To avoid any permission issues during this process,
I consistently create a tarball backup of the binary files using the following command:
To Create tar backup of ORACLE_HOME(19c)
My ORACLE_HOME installed on below location
ORACLE_HOME=/u01/app/oracle/product/db12.2
ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_1
cd /u01/app/oracle/product/19.0.0
tar -cvzf /backup/dbhome.tar.gz db_1
or
tar -cvzf backup_ORACLE_HOME_$(date +%F).tar.gz $ORACLE_HOME
This command archives and compresses the ORACLE_HOME directory into a tar.gz file, appending the current date to the filename for easy identification and retrieval.
untar
tar -xvzf /backup/dbhome.tar.gz -C /u01/app/oracle/product/19.0.0/db_1
Note:- the -C argument is used to specify the path to place the file.
It always recommended taking backup using root user, so that all permission will be reserved.