CPIO Restore

Please note that using the command cpio to back up to tape was successful. Used the below command:

time find /accts -print | cpio -oa --block-size=512 --format=newc --verbose -O /dev/nst0

I'm trying to restore from tape of a particular file and having issues. Below is the command to restore from tape:

 cpio -iv "/accts/bank/2day" "/accts/bank/lastyear" --block-size=2048 < /dev/nst0

Please assist if the above command to restore is correct. I tried using it but it does not restore. I was in the /bkp directory to do the restore.

Using different block sizes when creating a cpio archive and when reading that cpio archive is almost always going to fail.

hi,
i tried as per your request but it came up with an error below

cpio: read error: Cannot allocate memory

kindly assist.

I didn't request anything. I suggested that you use the same blocking factor when creating your cpio archive on tape and when trying to read that cpio archive from tape.

You will also need to be sure that you are reading from the same position on the tape as the position where you wrote the tape. On some systems, the device name /dev/nst0 would specify that the tape was to be opened with no rewind.

Note also that since you used absolute pathnames when adding files to the archive, the directory in which you are sitting when restoring those files does not matter.

So, exactly what command did you use when you created your archive and exactly what command did you use when you tried to read files from your archive? And which command gave you the diagnostic? (And, please use CODE tags when displaying all of the above!)

What operating system are you using?

What shell are you using?

1 Like

below is how we had archived

time find /accts -print | cpio -oa --block-size=512 --format=newc --verbose -O /dev/nst0

when restoring we used the below command

cpio -iv "/accts/bank/2day" "/accts/bank/lastyear" --block-size=512 < /dev/nst0

below is the error while restoring.

'cpio: read error: Cannot allocate memory

we are logged in as root with bash shell.

OS

Linux 2.6.9-78.ELsmp #1 SMP 2008 i686 i                                                                               686 i386 GNU/Linux

please assist on the above issue.

I don't use a Linux system, but the standard requires that operands follow options on the command line as in:

cpio -iv --block-size=512 "/accts/bank/2day" "/accts/bank/lastyear" < /dev/nst0

instead of:

cpio -iv "/accts/bank/2day" "/accts/bank/lastyear" --block-size=512 < /dev/nst0

And, I still question whether /dev/nst0 is the device name you should be using? Just for the fun of it, try the commands:

dd if=/dev/st0 of=/dev/null count=1
cpio -itv --block-size=512 < /dev/st0

My suspicion is that you are adding archives to the your tape (without rewinding the tape after you have written an archive) and then reading from an unwritten portion of the tape. But, without knowing what else has been done to that tape device between the cpio command that created the archive and the cpio command that is trying to read the archive, there is no way to know.

The error you are getting is one that I have never seen from cpio before. A read should not require memory allocation. Memory allocation for input buffers should have been done before trying to read anything.

Thanks for the assitance.
will try this weekend.