Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The dreaded cpio

Status
Not open for further replies.
Oct 17, 2006
227
I have just found out that one of our backups uses cpio!!

Could anyone give me some as I'm a little stuck!!

cd live systems mkdir robd this will be the dir I want to restore the file to.

cd robd

the backup uses block size

cpio -ictv -C32768 < /dev/st0 | grep jv-ediinp

is this the correct way to list the file you want??

cpio -icdv -C32768 < /dev/st0 | grep jv-ediinp
to restore?

Thanks
Robert
 
What's wrong with cpio? [smile]

Once you have located the full pathname you want using the first command, the following should work to restore it:

[tt]cpio -icdv -C32768 path/to/jv-ediinp < /dev/st0[/tt]

Annihilannic.
 
Hi

if I use
cpio -icdv -C32768 path/to/jv-ediinp < /dev/st0

so
cpio -icdv -C32768 /data/jvedi/jv-ediinp < /dev/st0

cpio: /data/jvedi/jv-ediinp not created: newer or same age version exists
/data/jvedi/jv-ediinp
2188650 blocks

how do you tell it what dir you want to go to . eg I'm in data/jvedi/robd??


Many Thanks

 
Assuming you don't need the newer version, can you not just rename and then restore the original?

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
You can also use the r flag to interactively rename the file.

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
sorry Kenny for sounding stupid but this is not something I really know

would the syntax be

cpio -icdvr -C32768 /data/jvedi/jv-ediinp < /dev/st0??

as I can't copy off a live file which is being used.
 
I tried this

cpio -icdrv -C32768 /data/jvedi/jv-ediinp < /dev/st0
cpio: warning: skipped 318653000 bytes of junk
 
Try using the --no-absolute-filenames option to allow you to restore it to a different location.

I'd say it's more likely to be an iffy tape. What file size showed when you did the -ictv earlier?

Annihilannic.
 
2188650 blocks

Try using the --no-absolute-filenames whats that in syntax??


Thanks

Robert
 
I didn't mean the total number of blocks in the archive, I meant the size of the individual file, for example in the red line below.

Here is an example of using the --no-absolute-filenames option. You just include it in the command line exactly as quoted.

[tt]$ pwd
/tmp
$ find foo
foo
foo/bar
$ find /tmp/foo -type f | cpio -o -O /tmp/test.cpio
cpio: /tmp/foo/bar: truncating inode number
1 block
$ cpio -ivt -I test.cpio
-rw-r--r-- 1 anni users 29 Nov 21 14:19 /tmp/foo/bar
1 block
$ cpio -ivt --no-absolute-filenames -I test.cpio
-rw-r--r-- 1 anni users 29 Nov 21 14:19 tmp/foo/bar
1 block
$ mkdir newdir
$ cd newdir
$ cpio -ivd --no-absolute-filenames -I ../test.cpio
tmp/foo/bar
1 block
$ find /tmp/newdir
/tmp/newdir
/tmp/newdir/tmp
/tmp/newdir/tmp/foo
/tmp/newdir/tmp/foo/bar
$[/tt]

You can see how it allows you to extract the file to a new location by using a relative pathname instead of an absolute one.



Annihilannic.
 
I kind of get what it is

so is this right??

1.pwd
2.data/live/robd
3. ls -l brings nothing empty dir.
4. find /data/jvedi jv-ediinp | cpio -o -O /data/jviinp.cpio
5. cpio - ivt -I jviinp.cpio
6. cpio -ivt --no-absolute-filenames -I jviinp.cpio
7. cpio -ivd --no-absolute-filenames -I ../jviinp.cpio
8. file should be there??


first of all is this right second where does it know what device to look at eg /dev/st0??

Thanks

 
Err... no, I was just creating a sample cpio archive as an example (using cpio -o). You don't want to create an archive (which you were doing in steps 1 through 4), just extract a file from one.

Per Ken's question, have you rewound the tape?

If so, then I *think* this should work:

[tt]mkdir /tmp/newdir
cd /tmp/newdir
cpio -icdvr -C32768 --no-absolute-filenames -I /dev/st0 data/jvedi/jv-ediinp[/tt]

The restored file should be in /tmp/newdir/data/jvedi/jvediinp.

All of this information is on the cpio man page (man cpio).

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top