Using cpio command to copy oracle installation dir from one partition to another

Hi
My dba told me to use cpio to copy oracle installation dir, here's what I want to do:

copy /home/oracle to /prodcontent/

How do I do this, my dba said that I should be in ORACLE_HOME /home/oracle/product/9.2 and copy the cpio file to /content/oracle/product/9.2
 (But I have dir 10.0.2 aslo in oracle root dir and I want to copy the entire root dir not just 9.2. to the new location, which doesnt have oracle installation). Then I want to remove ORACLE from home partition and create sym link to the new location which is easy, but want to understand more on how to use cpio. Thank you:)

atwork2003Asked:
Who is Participating?
 
Brian UtterbackConnect With a Mentor Principle Software EngineerCommented:
Sure. The cpio command  is very similar to tar. However, unlike tar, it takes a list of files to add to the
archive on standard input. That is what the "find" part of the command is doing, printing the name of every
file to transfer. Now, like tar, cpio will write an archive file, but it also has a "passthru" option to skip
the archive file step and just go right to unarchive step. So, when you do this kind of thing
with tar you end up running two tar command and doing reads and writes on each block four times, but with
cpio each block get read and written once, which is much more efficient.

You could do the same kind of thing with a simple "cp" command, but the cp command does not necessarily
do what you expect with symbolic links, hard links, special files and acls.  On Solaris at least, the cpio
command is usually the first to be updated to be compatible with new whizz bang features.
0
 
Brian UtterbackPrinciple Software EngineerCommented:
cd into the oracle root directory, and the execute this:

find . -depth -print | cpio -pamVd /new/rootdir/dir

where /new/rootdir/dir is the directory you want to contain the new copy.

0
 
atwork2003Author Commented:
Do I have to create oracle dir first in the new location like mkdir or just use the command you gave. Thank you so much for urgent response:)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
omarfaridCommented:
To copy please use

cd /my/old/dir (please put the correct one here)
find . -depth | cpio -pvd /newdir (please put the correct one here)

To remove, you may use (but be careful since you can not recover deleted files. Its better if you take backup on tape):

cd /my/old
rm -Rf dir
ln -s /newdir /my/old/dir
0
 
Brian UtterbackPrinciple Software EngineerCommented:
You should do a mkdir on the new directory before you do the command.
0
 
atwork2003Author Commented:
blu thank you so much for the update. Can you also explain what the command is doing, so I can do it myself next time:) Thank you so much:)
0
 
atwork2003Author Commented:
Awesome, one more thing what does -depth does. Thank you so much for such great response
0
 
Brian UtterbackPrinciple Software EngineerCommented:
It causes find to process all the files in a directory before the directory itself. Otherwise when the directory
had it's modified time set, the writes to the subdirectories and files would change it.
0
 
atwork2003Author Commented:
Thank you everyone for such great responses and help, I appreciate it very much:)
0
 
atwork2003Author Commented:
Exceptional guru, great and detailed responses
0
All Courses

From novice to tech pro — start learning today.