Operating System - HP-UX
1826203 Members
3016 Online
109691 Solutions
New Discussion

Backing up/Restoring Files Using CPIO

 
Jim Sobiesczyk
Frequent Advisor

Backing up/Restoring Files Using CPIO

Hello CPIO Gurus:

I'm having a problem where some of the directories that were backed up using 'cpio -ovcBdum' appear in the backup output log, but I cannot see them in any of the tape listings that I made using 'cpio -ivtcB /dev/rmt/0mn'.

The one directory that I need to restore never appears when I try to do a listing using cpio.

Also, since it's been a long-long time since I've used cpio, I was wondering if the syntax that I need to use for my restore would be to cd to the restore directory, and then do:
"cpio -ivcBdum < /dev/rmt/0mn [restore_of_directory] . " (The "." would be to put the data into the current directory. Is that correct)?

Any help would be greatly appreciated.
Knowledge comes, but wisdom lingers.
7 REPLIES 7
Prashant Zanwar_4
Respected Contributor

Re: Backing up/Restoring Files Using CPIO

backup is as below:

find / -depth | cpio -pdmuv /dev/rmt/dev_rmt (even dir can be specified instead of rmt)


http://www.backupcentral.com/cpio-restore.html

check this for your query
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Tiziano Contorno _
Valued Contributor

Re: Backing up/Restoring Files Using CPIO

I see you used the no rewind device, maybe you are at the wrong position on tape.

fsf or bsf command of mt.
man mt

Regards.
TwoProc
Honored Contributor

Re: Backing up/Restoring Files Using CPIO

That's probably going to be because those directories are empty. This is normal behaviour for cpio.
We are the people our parents warned us about --Jimmy Buffett
Jim Sobiesczyk
Frequent Advisor

Re: Backing up/Restoring Files Using CPIO

How do I put into a different directory? Just by cd'ing to my restore directory & puttinf a "." at the end of the cpio command-line?
Knowledge comes, but wisdom lingers.
TwoProc
Honored Contributor

Re: Backing up/Restoring Files Using CPIO

You won't be able to restore to a different directory unless you backed up the data starting with a "." .

Create

cd /sourcedir
find . | cpio -oBdmvuxc > /dev/rmt/0m

Restore

cd /targetdir
cpio -iBdmvuxc < /dev/rmt/0m

In the above scenario, all of the files would be prepended with a "./", once you've got that, you know you can recover those files just about anywhere.
We are the people our parents warned us about --Jimmy Buffett
Tiziano Contorno _
Valued Contributor

Re: Backing up/Restoring Files Using CPIO

The optional "dir" parameter at the end of the cpio -i command is actually a pattern: "according to the rules of Pattern Matching Notation (see regexp(5))" as from man cpio.

So you need to specify a regular exporession to match the directory you want to be restored.

"." matches only a single character.

Regards.
Peter Nikitka
Honored Contributor

Re: Backing up/Restoring Files Using CPIO

Hi,

if you use
cpio -ivcBdum < /dev/rmt/0mn [restore_of_directory] .
the dot does NOT mean, that the data is restored to '.' - this is always the case.
The dot in this context means just another pattern for the restore list and stands for itself.

If you want to restore 'olddir' to 'newdir', consider using 'pax' instead of 'cpio' - read the manpage, esp. option '-s'. However I must say, I never used this by myself.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"