Cover V03, I03
Article
Listing 1
Listing 2
Listing 3
Sidebar 1

may94.tar


Archiving Informix On-line from cron

Carl Nichols and Ed Schaefer

To achieve on-line transaction processing (OLTP) performance, the Informix On-line database engine manages its own resources, including creating (and restoring) database archives. Part of the archive process is backing up the logical log files, which are critical to Informix On-line data recovery.

Unfortunately, the Informix archive utility, tbtape, is designed only to be run in the foreground, and thus ties up resources such as monitors (or at least a window) and tape drives. This article presents an alternative procedure via a shell script for running archives and logical logging from a cron or the background. (Note: the shell script examples included within this article are the parameterized versions of the originals written at Newport News Shipbuilding, Newport News, VA).

What Is an Archive?

Informix defines archive-0 as a full database backup, with archive-1 and archive-2 being incremental backups. Between archives, logical log files which occupy contiguous disk space are released for re-use after a full logical log is backed up.

The General Solution

Since UNIX treats devices as files, you can change the archive and logging tape drives to disk files, thus sending archive data to a file rather than to tape. On-line is controlled by a configuration file pointed to by TBCONFIG; within this file, change the archive device, TAPEDEV, and the logging device, LTAPEDEV, to disk file names.

Also, UNIX permits standard input to be redirected from the keyboard to an ASCII file, which allows interactive commands, such as tbtape, to be run in the background. The ASCII files needed are arch_0, arch_1, and arch_2, with the first line being an octal carriage return, \012, and the second a 0, 1, or 2, depending on the archive. Also, the file tbtape_cr contains just one line, consisting of the same octal carriage return. Below is the file arch_0:

\012
0

The Archive Script: archive.sh

You create an archive by calling archive.sh (Listing 1) with the proper 0, 1, or 2 argument. The script does the following:

  • Stops logical logging by calling the Ktbtape.sh script (Listing 2)

  • Performs the actual archive 0, 1, or 2

  • Re-starts logical logging in the background by calling the Stbtape.sh script (Listing 3).

    Since the scripts are relatively straightforward, we concentrate here on potential On-line problems.

    Warnings

    1. Check the parameterized commands for pathname accuracy for your system.

    2. Make sure the shell scripts and the redirected ASCII files mentioned earlier are in the $PWD directory.

    3. Make sure that archive.sh is only called from the user "informix" cron.

    4. If you attempt to change TAPEDEV, LTAPEDEV, TAPESIZE, or LTAPESIZE using the Informix DBA utility, tbmonitor, the file or device must exist and be owned and readable by user "informix".

    5. Be sure the $BACKARCDIR and $BACKLOGDIR file systems are large enough to hold the largest expected archives, and are not on the same drive as the database partition.

    Restoring an Archive

    Archives are restored from the archive section of the tbmonitor utility. tbmonitor will ask the for the base archive-0 and any archive-1 or archive-2 files. Each archive file must be uncompressed if need be, and moved to the value of TAPEDEV. After the last archive is restored, any logical logs file(s) must be restored. The logical log file(s) must be moved to the value LTAPEDEV.

    In Summary

    Using cron or a background process to archive files to disk may free your resources, but you must also develop a detailed plan for saving the necessary files. For example, each archive level and the copied "full" logical logs after the last archive should be maintained for recovery purposes.

    About the Authors

    Carl Nichols is a technical consultant and UNIX system administrator who has been working with AT&T Global Information Solutions since 1981 and with UNIX-based systems since 1985. Carl helped design, test, and implement a 31-node Informix On-line distributed database Time and Attendance System at Newport New Shipbuilding, Newport News, VA. He now administers the system and has automated significant portions of daily operational tasks.

    Ed Schaefer is an Informix software developer and UNIX system administrator at jeTECH Data Systems of Moorpark, CA, where he develops Time and Attendance Software. He has been involved with UNIX and Informix since 1987 and was previously head of software development at Marie Callendar Pie Shops of Orange, CA.


     



  •