From: aray@skyserv4.med.osd.mil ("Alicia Ray")
Subject: tbtape -s archives
Date: 23 Apr 1996 18:38:06 -0400
Newsgroups: comp.databases.informix
X-Informix-List-ID: <list.9536>

We are currently running Informix 5.03 on a DG/UX platform. Most
system administration tasks have been automated for deployed sites
so that the operators at each site aren't burdened with certain
administration tasks.  However, they are responsible for labeling
tapes, loading tapes, circulating tapes (so as not to overwrite
previous archives), etc.

Well unfortunately from time to time the operators have problems
performing those tasks as well.  Sometimes the operators have not
labeled the tapes well and lose track of which tape is from what day.

Is there a way to get a timestamp from an archive tape (compressed)
and verify what level archive (0, 1 or 2) was performed?

A colleague of mine wrote:

We are performing our archives to the "compressed" drive which has
worked.  The tapes are 2GB DAT tapes but in using the compressed
tape drive we have been able to get over 6GB on one tape when doing
a level 0 archive.

I've used od -c (device) | more.  This has shown me an Informix
"label" and our tbconfig information and then data.  I could not see
anything that looked like a timestamp or what level archive the
archive is.

Informix's response was that there was no way of getting the
information that they knew of but they were told by a customer that
the customer was able to get a timestamp by performing:

	"dd if=(device) of=(output file) bs=16k count=1"

I used this and was still not getting a timestamp basically it's the
same data that I got from the octal dump, of course.  I played with
different bs's since this command is just reading the first 16k off
the tape but could not see anything.

I tried tail on the device but came up with NULL in the output which
suprised me.  I just used the default for tail and maybe if I used a
value I would get another result.  The tail took quite awhile and
before I play anymore I would like some further direction from anyone
who has ever attempted to find what I am looking for on an archive tape.

Thanks in advance,
Dan Maruschak
Alicia Ray

-- 
**********************************************************************
Alicia Ray                      Internet : Alicia.Ray@med.osd.mil
EDS-D/SIDDOMS                   Phone    : 703-845-3807
5113 Leesburg Pike
Skyline 4 Suite 800
Falls Church, VA 22041-3201
**********************************************************************

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: ptm@xact.demon.co.uk (Paul Mahoney)
Subject: Re: tbtape -s archives
Date: Wed, 24 Apr 1996 06:23:10 GMT
Newsgroups: comp.databases.informix

The following code should help...

#!/bin/sh
#
# This is a shell archive.  To extract its contents,
# execute this file with /bin/sh to create the file(s):
#
# tbheader.c
#
# This shell archive created: Fri Aug 23 11:53:16 EDT 1996
#
echo "Extracting file tbheader.c"
sed -e 's/^X//' <<\SHAR_EOF > tbheader.c
X#include <stdio.h>
X#include <time.h>
X
Xextern	int	getopt	();
Xextern	char*	optarg;
Xextern	int	errno;
X
Xchar*	print_date		();
Xint	read_tape_header 	();
X
X#define ARCH_TAPE       99
X#define LOG_TAPE        100
X#define BADHEADER       101
X#define BADBLOCKSIZE    102
X
X#define PG_TAPEHDR      -1L                     /* tape header page     */
X#define PG_LOGHDR       -2L                     /* logical log hdr page */
X#define PG_TRAILER      -3L                     /* trailing hdr page    */
X#define PG_BEGINBPG     -4L                     /* tape Blob log header */
X#define PG_ENDBPG       -5L                     /* tape Blob log trailer*/
X
X#define BSYSTEM         0x0000                  /* system backup        */
X#define BAUTOLOG        0x0001                  /* auto back up of llog */
X#define BPILOT          0x0002                  /* continuous back up   */
X#define BLGCLOGS        0x0004                  /* logical log backup tape */
X#define BINCARCH        0x0008                  /* incremental archive tape*/
X#define BSYSMIRR        0x0010                  /* system mirror flag   */
X
Xtypedef	long	int4;
Xtypedef short	int2;
X
Xtypedef struct page
X    {
X    int4 pg_addr;       /* physical page address        */
X    int4 pg_stamp;      /* time stamp counter           */
X    int2 pg_nslots;     /* number of slots used         */
X    int2 pg_flags;      /* flag bits                    */
X    int2 pg_frptr;      /* first free byte              */
X    int2 pg_frcnt;      /* number of bytes free         */
X    int4 pg_next;       /* for btrees = next node at same level */
X    int4 pg_prev;
X} page_t;
X
Xtypedef struct archive
X    {
X    int4 ar_realtime;           /* real time when archive begins */
X    int4 ar_timestamp;          /* timestamp when archive begins */
X    int4 ar_logid;              /* log unique id when archive begins */
X    int4 ar_logpos;             /* logical log pos at beginning of archive */
X} archive_t;
X
X#define PG_TYPE(x) (x & 0x1f)   /* Where to find the page type in pg_flags */
X
X/************************************************************************/
X
Xmain (int argc, char* argv[])
X{
X    char*	tape_dev = NULL;
X    FILE*	tape_fd;
X    int		ch, errflg = 0;
X
X    while ((ch = getopt (argc, argv, "t:")) != -1) {
X	switch (ch) {
X	    case 't':	tape_dev = optarg;	break;
X
X	    default:	errflg++;		break;
X	}
X    }
X
X    if (errflg || !tape_dev) {
X	fprintf (stderr, "Usage: tbheader -t <tape_dev>\n");
X	exit (1);
X    }
X
X    if ((tape_fd = fopen (tape_dev, "r")) == NULL) {
X	fprintf (stderr, "Failed: Opening tape device %s\n", tape_dev);
X	exit (1);
X    }
X
X    exit (read_tape_header (tape_fd));
X}
X
X/************************************************************************/
X
Xint read_tape_header (FILE* tape_fd)
X{
X    short	tapetype;
X    page_t	page;
X    archive_t 	archive;
X    int		i;
X
X    if (fread (&page, sizeof (page), 1, tape_fd) != 1) {
X	fprintf (stderr, "Failed: Reading page header - errno = %d\n", errno);
X	return (-1);
X    }
X
X    if (page.pg_addr != PG_TAPEHDR) {
X	fprintf (stderr, "Failed: Bad page header\n");
X	return (-1);
X    }
X
X    printf ("TAPE HEADER INFO:\n");
X
X    if (page.pg_flags&BSYSMIRR) {
X	printf ("\tMirror flag is on.\n");
X	page.pg_flags &= ~BSYSMIRR;
X    }
X
X    switch (page.pg_flags) {
X	default:	printf ("\t-*-UNKNOWN-*-\n");
X			return (-1);
X
X	case BSYSTEM:	printf ("\tSystem Backup Tape\n");
X			tapetype = ARCH_TAPE;
X			break;
X
X	case BAUTOLOG:	printf ("\tAuto Log Backup Tape\n");
X			tapetype = LOG_TAPE;
X			break;
X
X	case BPILOT:	printf ("\tContinuous Log Backup Tape\n");
X			tapetype = LOG_TAPE;
X			break;
X
X	case BLGCLOGS:	printf ("\tLog Backup Tape\n");
X                        tapetype = LOG_TAPE;
X                        break;
X
X	case BINCARCH:
X	    printf ("\tIncremental Archive Tape. Level %d, Part %d\n",
X			page.pg_nslots, page.pg_frcnt);
X	    for (i = 0; i <= page.pg_nslots; i++) {
X		if (fread (&archive, sizeof (archive), 1, tape_fd) != 1) {
X		    fprintf (stderr,
X			     "Failed: Reading acrhive record - errno = %d\n",
X			     errno);
X		    return (-1);
X		}
X	    }
X
X	    printf ("\tCreated on %s", print_date (archive.ar_realtime));
X	    tapetype = ARCH_TAPE;
X	    break;
X    }
X
X    printf ("\tTape block size is %dk\n", page.pg_next);
X    printf ("\tTape size is %dk\n", page.pg_prev);
X
X    if (tapetype == LOG_TAPE) {
X	printf ("\tTape %d created on %s",	page.pg_frcnt,
X						print_date (page.pg_stamp));
X    }
X
X    return (0);
X}	
X
X/************************************************************************/
X
Xchar* print_date(long datetime)
X{
X    struct tm   *tm;
X    struct tm   *localtime();
X    static char  datestr[20];
X
X    tm = localtime(&datetime);
X
X/*    sprintf(datestr, "%02d/%02d/%02d", tm->tm_year, tm->tm_mon+1, tm->tm_mday);
X    datestr[8] = datestr[9] = ' ';
X    sprintf(&datestr[9], "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
X
X    return (datestr);
X    */
X    return (asctime (tm));
X}
X
SHAR_EOF
if [ `wc -c < tbheader.c` -ne     4894 ]
then
    echo "Lengths do not match -- Bad Copy of tbheader.c"
fi
echo "Done."
exit 0

Regards

Paul.
-- 
---
Paul Mahoney, X-Act Solutions Limited
smail: Owlsmead, Meads Road, Little Common, Bexhill-on-Sea, East Sussex TN39 4SY
email: ptm@xact.demon.co.uk ... pmahoney@cix.compulink.co.uk
