3

I have a basic backup to tape script and restore script that was written by a previous admin. When trying to restore from tape, I get the following error:

tar: v: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

I have tried running the commands manually to enter in the restore path: tar -xfv /dev/st0 /srv

I have also tried restoring to alternate paths, all which give the same error message. Below are the backup and restore scripts. Any help identifying what my issue is would be greatly appreciated.

Here is the backup script:

echo Starting backup to tape at `date`
mt -f /dev/st0 rewind
tar cfv /dev/st0 /srv
mt -f /dev/st0 eject
echo Backup to tape complete at `date`
exit

Here is the restore script:

echo -n Starting restore from tape at `date` to directory: `pwd`
mt -f /dev/st0 rewind
tar -xfv /dev/st0
echo Restore from backup complete at `date`
exit

1 Answer 1

0

The options of the tar command is wrong in the restore script. This works:

tar xfv /dev/st0

The only difference is the missing minus, however that is quite important. If you use the '-' then you are using the usual GNU options syntax. In that case the 'f' option must be followed by the file name. In your script 'f' is followed by a single 'v' letter. So tar tried to extract from the file named 'v'. Which does not exist as the error message correctly says.

If the first argument does not start with the '-', than you are using the old, but quite comfortable tar syntax. In this case the required arguments of the options follow the entire set of the options. Now 'v' means verbose, as expected, and the source file is the tape drive (/dev/st0), as expected.

From the GNU tar documentation at http://www.gnu.org/software/tar/manual/tar.html#SEC36:

As far as we know, all tar programs, GNU and non-GNU, support old options: that is, if the first argument does not start with '-', it is assumed to specify option letters. GNU tar supports old options not only for historical reasons, but also because many people are used to them. If the first argument does not start with a dash, you are announcing the old option style instead of the short option style; old options are decoded differently.

Like short options, old options are single letters. However, old options must be written together as a single clumped set, without spaces separating them or dashes preceding them. This set of letters must be the first to appear on the command line, after the tar program name and some white space; old options cannot appear anywhere else. The letter of an old option is exactly the same letter as the corresponding short option. For example, the old option 't' is the same as the short option '-t', and consequently, the same as the long option '--list'. So for example, the command 'tar cv' specifies the option '-v' in addition to the operation '-c'.

When options that need arguments are given together with the command, all the associated arguments follow, in the same order as the options. Thus, the example given previously could also be written in the old style as follows:

$ tar cvbf 20 /dev/rmt0

Here, '20' is the argument of '-b' and '/dev/rmt0' is the argument of '-f'.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .