We have a Unix database that completes a cold backup to tape every night. The files are written out using their full pathname using the cpio command. We need to restore these files to a different pathname for creating test database purposes. I have looked at the cpio -r option but this seems to only be available in interactive mode. We need a way of batch processing this cpio -r for multiple datafiles... any advice and/or scripts would be appreciated.

    Requires Free Membership to View

There are a couple of options for you. One option is to use a scripting language called Expect. Expect is a scripting language that can interface with any command line interface. You tell Expect what to "expect", and your Expect script will supply the next answer. For instance, you can invoke SQL*Plus from Expect. You tell Expect to expect the prompt for the username. Then, when Expect sees this prompt, it passes the supplied username to the SQL*Plus executable. You can use it to do the same thing in your example. Have your Expect script call "cpio -r" for you. Tell it what to expect in return and how to respond to that prompt. Expect is one of the great scripting languages that no one talks about!

Otherwise, you might want to consider dropping the directory path from your files that you archive with cpio. Or consider using something other than cpio to do the archive.

For More Information


This was first published in January 2003

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.