1825766 Members
2682 Online
109687 Solutions
New Discussion

cpio

 
Tonatiuh
Super Advisor

cpio

HP-UX 11.11.

I want to copy into only one archive, de contents of a directory and all its subdirectories and files.

What is the sintax to do this using CPIO ?
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: cpio

cd to desired directory.
find . -print | cpio -ocv > /xxx/yyy/myfile.cpio

If you want to send it to tape:

find . -print | cpio -ocBv > /dev/rmt/0m
If it ain't broke, I can fix that.
Robert Bennett_3
Respected Contributor

Re: cpio

cd to the directory you want to archive then:
find . -depth -xdev -print | cpio -dump /newmountpoint

Hope this helps

B
"All there is to thinking is seeing something noticeable which makes you see something you weren't noticing which makes you see something that isn't even visible." - Norman Maclean
TwoProc
Honored Contributor

Re: cpio

Here's what I commonly use... BUT, you should really read the man pages for both find and cpio and review ...
cd /source_dir
find . -xdev -depth | cpio -oBdvmxc > /dev/rmt/0m

This would take all the files in /source_dir and all of the files in all of the subdirectories of /source_dir and put them on the tape drive.

find options...
"xdev" -makes sure it doesn't cross mount points.
"depth" uses a depth first search instead of a breadth first search - recommended.

cpio options
"o" - output
"B" - large blocks
"d" - create directories as needed - probably don't need when making a tape - but I like using it both in and out - so my command looks almost the same on extract... bad excuse I know...
"v" verbose
"m" preserve modification times
"x" preserves special files (think /dev)
"c" ascii format - b/c I like it better.

Now, to extract from the tape...
cpio -iBdvmuxc < /dev/rmt/0m ...
(keep in mind that the "u" is an option for overwriting a newer file with an older one).

HTH
We are the people our parents warned us about --Jimmy Buffett
Uday_S_Ankolekar
Honored Contributor

Re: cpio

cd to desired directory and run
find . -depth | cpio -pdlmuva /destination_dir

-USA..
Good Luck..
Tonatiuh
Super Advisor

Re: cpio

I have created a CPIO file using:

find . -print | cpio -ocv > myfile.cpio

But I cannot recover it. I have tried with:

cpio -idcmv > myfile.cpio
cpio -idmv > myfile.cpio

Any idea?
Suraj_2
Valued Contributor

Re: cpio

Hi

Check the redirection symbol
Is it not "<" instead of ">"

Rgds
Suraj