SUMMARY:dd to extract dump header

From: Louis Fidel (lfidel@fldev.nsf.gov)
Date: Mon Jan 09 1995 - 12:49:59 CST


Original Message:

> I'm running Sun OS 4.1.3 and have a problem with dump/restore.
> As part of our backup script I need to ensure the operators change the
> tape cartridges every morning. I'd like to do this by reading the header
> which dump writes to the dump file.
>
> Unfortunately, The header is only available through interactive restore
> ( restore -i ) which is not convenient to run from a backup script.
>
> Seems my only recourse is to use dd but I haven't had success.
> Is it possible to read the header with dd? If so what arguments do I give it?

__
SUMMARY

Although Rick Pluta gave me what I asked for, there were several easier
solutions. First by using a HERE document I could do an interactive restore
and then read the header(Aaron). Or I could use restore do a non-recursive
restore of the root directory with restore vtfh <device>. Many responses advised
using tar to first write the header file.
Of course mt offline will keep the next day's dump from being overwritten.

Thanks to all(25 responses).

Louis Fidel
____

        We had the same situation here, but we DID use the restore -i scheme.
We have a ksh script which contains:

<setup stuff removed>
/etc/restore -ivf /dev/nrst8<<-REOF > $TMPFILE 2>&1
quit
REOF

DUMPSTRING=$(grep "$GREPSTRING" $TMPFILE)

integer DUMPDATE=$(echo "$DUMPSTRING" | cut -c22-23)

        Then do some "if"s based on $DUMPDATE to see if Yesterday's
tape is still in the drive, and mail the output to the tape apes. (operators)
Of course, be sure to remove the TMPfile on exit.

Aaron
                                        cammaa@mcsunx.gs.com

_________

To use dd to extract the dump header, you must specify the same block size
that was used to create the tape (ie- 126). A command such as the following
should work (remember to use your block size in place of 126):

dd if=/dev/your_tape_dev of=/tmp/dump_hdr bs=126b count=1

After this command, the output file (/tmp/dump_hdr in the example above)
should contain the first block from the tape. The first 1024 bytes make up
the dump header (TS_TAPE record).

>From this TS_TAPE record, you need to extract the information you desire.
A C or perl program would most likely be your best bet. Refer to the include
file "/usr/include/protocols/dumprestore.h" for dump header structure info.

Rick Pluta

______

 Many people put a tape label on ahead of the normal backup files ( dd tar ...)
This is usually indicative as to the contents of the following backup. Don't
forget to use the no-rewind option so that the dump itself does not overwrite
the label!

  This could then be retrieved and used to verify if tapes are being rotated
properly.

  To ensure that tapes don't get over-written, use mt offline to kick them out.

Jim Hebert

____

We do this by writing a reference file to the root of the filesystem before
backing up, and then doing a selective restore of that file to find
out what is on the tape. This seems to work well.

Dave Plummer, UCL Hospitals, London UK

_______

Include in your script lines like the following to label a tape....
   rm /home1/datestamp.*
   touch /home1/datestamp=`date +%d%h%y`

Use a command like
 restore -tf /DEV/TAPEDEV datestamp=`date +%d%h%y`
to check whether the current day's tape is still present.

(Backups done the same day, eg started at 4am, tested at 9am)

_______
> /usr/etc/restore -vtfh /dev/nrst1
Verify volume and initialize maps
Media block size is 56
Extract directories from tape
Initialize symbol table.
Dump date: Fri Jan 6 01:58:35 1995
Dumped from: Fri Dec 16 13:36:48 1994
Level 5 dump of /export/bootes on bootes:/dev/sd0h
Label: none
dir 2 .
>

We just dump a file containing the tape name at the start of the tape.
But then we only use one tape for the whole week.

Anthony.Worrall@Reading.ac.uk

_____



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:13 CDT