Re: tbtape help
Posted in 1994
maury@bnr.ca (Maury French) writes:
>Hello, all. Simple Question. Informix Online 5.01 running on an HP H20, hpux
>9.0. I want to backup to tape automatically, 2am or so, full backup
>every night. Or should I say, level 0 archive. Anyway, the command I
>believe is tbtape but it is interactive. How do I make it automatic?
Maury,
Don't know if this is the most efficient way, but here's how I set
it up at one of my clients. I wrote the C program to check the
tape device. If you don't check, and there's a problem, tbtape goes
into an infinite loop of prompts. The script can simply be called
by cron.
Troy
--------------------------- CLIP HERE -----------------------------
#!/bin/sh
#
# Set Informix-OnLine parameters
#
TBCONFIG=tbconfig.test
INFORMIXDIR=/usr/informix
export INFORMIXDIR TBCONFIG
#
# Determine the device being used for the archive
#
DEVICE=`grep "^TAPEDEV" $INFORMIXDIR/etc/$TBCONFIG | awk '{print $2}' -`
echo "Device: $DEVICE"
#
# If the device is readable/writable start the archive
#
chkdev $DEVICE # C program to test device (see below)
if [ $? = 0 ] ; then
echo "Creating Archive"
echo "\\n0\\n" | $INFORMIXDIR/bin/tbtape -s
else
echo "Unable to create archive"
fi
#---------------------------------------------------------------------------#
# E N D O F P R O G R A M #
#---------------------------------------------------------------------------#
--------------------------- Clip Here -----------------------------
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
/*--------------------------------------------------------------------------*/
main(argc, argv)
int argc;
char *argv[];
{
if (argc != 2)
{
fprintf(stderr, "Usage: %s device-name\\n", argv[0]);
exit(1);
}
if (open(argv[1]), O_RDWR, "w") == -1)
{
perror("O/S Error");
exit(errno);
}
exit(0);
}
/*---------------------------------------------------------------------------*/
/* E N D O F P R O G R A M */
/*---------------------------------------------------------------------------*/