1840349 Members
2692 Online
110162 Solutions
New Discussion

Re: cpio retrieve a file

 
Hanry Zhou
Super Advisor

cpio retrieve a file

How to retrieve a particular file(only one) from the tape by using cpio?

Thanks!
none
9 REPLIES 9
S.K. Chan
Honored Contributor

Re: cpio retrieve a file

It depends on what cpio options do you use when you backed up the file to tape at the first place. Typically ..(assuming tape device is /dev/rmt/2m) you can try this and see if it works ..
# cpio -icvdxumB < /dev/rmt/2m 'filename'
Helen French
Honored Contributor

Re: cpio retrieve a file

Depend on the options used while your tape was created. For eg:

# cpio -icdumv ./tmp/test.txt < /dev/rmt/0m

This command will assume the backup was created using relative path and you should use the exact path name as it is in the tape.
Life is a promise, fulfill it!
Helen French
Honored Contributor

Re: cpio retrieve a file

Also, it is possible to use wild card characters if you are not sure about the real file name or path name:

# cpio -icdumv "./tmp/shiju/*" < /dev/rmt/0m

This will restore all files from /tmp/shiju to the current directory.
Life is a promise, fulfill it!
Hanry Zhou
Super Advisor

Re: cpio retrieve a file

I am not sure what path I have used, relative or full path?
none
Richard Hood
Advisor

Re: cpio retrieve a file

since you are not sure what was written to the tape: You will need to first identify the file you need to restore


cpio -itB >/tmp/tape.out (creates output of tape contents)

grep [filename] /tmp/tape.out

cpio -iBdmuvc (output from step 2)
If it ain't broke - Don't fix it
Frank Slootweg
Honored Contributor

Re: cpio retrieve a file

Note that you also need the right combination of the "c" and "B" options ("c", "B", "cB" or neither/nothing), so it helps if you know the combination which was used when writing the tape. If you don't know, then say so and we will explain how to find out.
Ravi_8
Honored Contributor

Re: cpio retrieve a file

Hi,

depend on the options used while your tape was created (absolute/relative path)

assuming absolute path is used

# cpio -icdv < /dev/rmt/0m/

(assuming /dec/rmt/0m is the tape drive)
never give up
Keely Jackson
Trusted Contributor

Re: cpio retrieve a file

Hi

If you don't know how the cpio archive was created you can always try and extract the file using pax, eg pax -r -f archive filename

See man pax for the all parameters you need as I can't remember the exact syntax.

Cheers
Keely

Live long and prosper
Thomas Greig
Regular Advisor

Re: cpio retrieve a file

Is it possible to extract the whole tape
with cpio (even if the tape have been created in different groups)?

say the tape consists of several groups of data, created with cpio.
I'm looking for a quick method of extracting all the data-groups on the tape.

regards
Thomas Greig