return to PRS Technologies website


Logical Log Backup to Disk



OK, backing up your logical logs to disk (vs. tape) seems a little cross-purpose, but if you want to back up your logical logs, don't have a tape drive, and copy the logs to a physical disk other then where the logs live, this might be one way to do it.

One might notice there is no restore process documented here. That still needs to be written and tested.



First, create a 'named pipe' to simulate a tape drive to write to. Name it 'logbackup.pipe'.

What is a 'named pipe' ???, you ask...

A named pipe is a special file that is used to transfer data between unrelated processes. One (or more) processes write to it, while another process reads from it. Named pipes are visible in the file system and may be viewed with `ls' like any other file. (Named pipes are also called fifos; this term stands for `First In, First Out'.)

Named pipes may be used to pass data between unrelated processes, while normal (unnamed) pipes usually only connect parent/child processes. Named pipes are strictly unidirectional, even on systems where anonymous pipes are bidirectional (full-duplex).

How do I create a named pipe?

To create a named pipe interactively, you'll use either mknod or mkfifo.

Using mkfifo...

/* set the umask explicitly, you don't know where it's been */
umask(0);
if (mkfifo("logbackup.pipe", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
{
    perror("mkfifo");
    exit(1);
}

If you don't have mkfifo, you'll have to use mknod:

/* set the umask explicitly, you don't know where it's been */
umask(0);
if (mknod("logbackup.pipe",S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,0))
{
    perror("mknod");
    exit(1);
}
Change the Informix ONCONFIG parameter LOGTAPEDEV to point to the logbackup.pipe. Use a symbolic link if preferred.



Implement the alarmprog1.sh script by changing the Informix ONCONFIG parameter ALARMPROGRAM to point to alarmprog1.sh.

Make sure the reference to log_full.sh (normally used when implementing on-bar) is NOT commented out.

Change the BACKUP_CMD parameter to point to point to a new script that looks like this: ################################################################################ LOGBACKUPDIR=/u2/backup/logs LOG_BACKUP_FS='dirname $LOGBACKUPDIR` # Unix filesystem where the logical logs are written to DAYS_TO_KEEP=5 LOGTAPEDEV=`onstat -c| grep LTAPEDEV |awk '{print $2}'` LOGNUM=`onstat -l|grep "\-C-"|awk '{print $4}'` # Determine current logical log LOGFILE=`expr ${LOGNUM} - 1` # Backup the previous log echo "Back up log ${LOGFILE}" if [ -s ${LOGBACKUPDIR}/${LOGFILE}.LOG.Z ] then echo "This log backup file already exists! This is unexpected. Aborting!" exit 1 fi PERCENT_USED=`bdf | grep "$LOG_BACKUP_FS" | awk '{printf("%d",$5)}'` # Determine free space on disk if [ $PERCENT_USED} -gt 70 ]; then # Used more than 70 % of available space ? echo "Delete log files older then ${DAYS_TO_KEEP} days old..." find ${LOGBACKUPDIR}/. -name \*[0-9].LOG.Z -type f -mtime +${DAYS_TO_KEEP} -exec rm -f {} \; & fi # Start a process to read from the named pipe and save to a compressed Unix file. cat ${LOGBACKUPDIR}/logbckup.pipe | compress > ${LOGBACKUPDIR}/${LOGFILE}.LOG.Z & # Start writing the Informix logical logs to the named pipe. ontape -a <<EOF n EOF echo "Logical log backup of log ${LOGFILE} complete" ################################################################################