>I am looking for a script that someone posted to this list a while ago.   It
>allows you to get a listing of what is on the backup tape.  ...

How about just:

  mt -f $TAPE rewind
  amrestore $TAPE no-such-host

This asks amrestore to find backups of "no-such-host", which it won't
find, but as it goes through the tape it will tell you about everything
it skips over.

If that's not fancy enough :-), I think the appended script from Gerhard
den Hollander might be what you were thinking of.

>I have problems
>that since I use 2 tapes per backup, the amtoc that I use either reports
>just what is on the second tape or reports completely incorrect information.

Here's what I used to do at 2.4.1p1 (ksh, adjust as needed):

  ###
  # Generate a table of contents for the tape(s) just written.
  ###

  diff tapelist.0 tapelist \
    | grep '^> ' \
    | while read flag date label junk
  do
     echo "Creating TOC for $label"
     ${DEBUG} $base/sbin/amtoc ${config} -f -l $label
  done

At 2.4.2 it looks like this:

  ###
  # Generate a table of contents for the tape(s) just written.
  ###

  log=$(ls -1t log.????????.[0-9] | head -1)
  echo "Running $base/sbin/amtoc -a -s 's,/,_,g' $log"
  ${DEBUG} $base/sbin/amtoc -a -s 's,/,_,g' $log

I wouldn't know about amtoc reporting "completely incorrect information"
since you didn't give enough details to help figure that problem out.

>Michael Hendrix

John R. Jackson, Technical Software Specialist, [EMAIL PROTECTED]

#!/usr/bin/perl

$device = shift || die "Please specify full tapedevice\n";
$dd = "/bin/dd";
$mt = "/bin/mt";

print "Rewinding\n";
system("$mt -f $device rewind");

$tapeheader = `$dd if=$device bs=32k count=1`;
die "Amanda Label not found!\n$tapeheader\n" unless $tapeheader =~ /TAPESTART/;
print $tapeheader;
push(@stuff,$tapeheader);

while ( ! $ierr ){
    $foo = `$dd if=$device bs=32k count=1 | head -3`;
    if ($foo =~ /TAPEEND/) {
        print $foo;
        last;
    } elsif ($foo =~ /FILE/) {
        print $foo;
    } else {
        $foo =~ tr/A-Za-z0-9 \t\r\n/ /cs;
        print "Unexpected thing: $foo\n";
    }
    $ierr = $?;
}
print "Rewinding\n";
system("$mt -f $device rewind");

Reply via email to