How to restore files from cpio backup

Hi All,

My EOD program write backup using following command:

cd /; cpio -ocB 2 >> /base/misc/logs/bk.CopyToTape < /base/work/BACKUP.01022 1>/dev/rm0

How to restore single file from this backup? Any idea?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


what is this "BACKUP.01022" ? A single file?

Restoring this file should obviously be possible with

cpio -ic "/base/work/BACKUP.01022" </dev/rmt0

If there are several cpio archives on your tape, take care to position it correctly beforehand!


tayyabq8Author Commented:
Dear Mr. wmp,

Thanks for your answer, how to list the contents of this tape? Let me first check what is there on tape, then I'll try to restore one single file.
cpio -ictv </dev/rmt0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

tayyabq8Author Commented:
I get following error:

# cpio -itv < /dev/rmt0
cpio: 0511-037 Cannot read from the specified input.
Enter the device or file name when ready to continue.

Even I tried

# cpio -itvB < /dev/rmt0

But got following erro:

 cpio: 0511-903 Out of phase!
         cpio attempting to continue...

 cpio: 0511-904 skipping 43628 bytes to get back in phase!
         One or more files lost and the previous file is possibly corrupt!

cpio: 0511-027 The file name length does not match the expected value.

Any idea?
Use the "-c" flag if you used it to create the archive!
tayyabq8Author Commented:
Thanks again for your prompt reply but error is same, now i'm using command:

# cpio -ictvB < /dev/rmt0
cpio: 0511-037 Cannot read from the specified input.
Enter the device or file name when ready to continue.

It takes little more time (more than 10 minutes) and then it throws same error. Thanks for your support.
So we'll have to check what the tape might contain.

Please double-check that the tape drive is ready and has the correct tape mounted, then issue:

1) first file

tctl -f /dev/rmt0 rewind
dd if=/dev/rmt0 of=/tmp/rmt0.check1 bs=1024 count=1

2) second file (if any)

tctl -f /dev/rmt0 rewind
tctl -f /dev/rmt0.1 fsf 1
dd if=/dev/rmt0.1 of=/tmp/rmt0.check2 bs=1024 count=1

3) maybe there is even a third file?

tctl -f /dev/rmt0 rewind
tctl -f /dev/rmt0.1 fsf 2
dd if=/dev/rmt0.1 of=/tmp/rmt0.check3 bs=1024 count=1

If there are error messages please report them, and examine the contents of the output files /tmp/rmt0.check1 and maybe /tmp/rmt0.check2 and  /tmp/rmt0.check3.

Do they contain data which look valid? If in doubt, please attach the files to your next posting.


tayyabq8Author Commented:
It created first file, which is in some binary language, I can only understand first line of that file which is relevant to me, second file was not generated, it gives following error:

# tctl -f /dev/rmt0 rewind
# tctl -f /dev/rmt0.1 fsf 1
/dev/rmt0.1 fsf 1 failed: There is an input or output error.
What's in that first line? Valid cpio data?
tayyabq8Author Commented:
This is what it contains:

demo/compdir/autodata/data/AK/10/10.AK.index¿ØÉKl Ó¿2(

And then binary language follows.
This looks like a valid cpio header in ASCII format.

So the following commands should indeed work, if the tape is mounted and the tape unit made ready:

tctl -f/dev/rmt0 rewind
cpio -ictvB </dev/rmt0

Since you get an error with the above, we have to assume that there is some damage, probably with the tape medium itself.
What does "errpt |more" say? Some entries related to rmt0?

Could you create a new tape (whichever data you use, that's irrelevant), and try to get a table of contents for this new one?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tayyabq8Author Commented:
Thanks a lot for your support, I'm able to restore a single file, it was tape cartridge issue, I wrote a new copy of backup and it worked fine.
tayyabq8Author Commented:
I appreciate  woolmilkporc's help, he was very responsive and his suggestions were very logical.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.