6. backup

This section describes how to use the backup service to perform un-attended backups.

backup & restore manager

The infx backup service uses the infx BAR manager to map backup service types to backup commands. 

For example, you could map the logs backup to the ontape -a command, to the onbar -b -l command, or, to your own script.

For the purposes of this guide, I will use the default BAR manager settings for ontape backup to directories. For details on setting up for other backups, see:8. BAR manager

The backup functions supported by infx are:

 function  description
 dbs  Backup of storage spaces
 ext  External backup
 fake  Does no actual backup, but sets flags etc
 hot  Perform backup to STDOUT, part of the hot copy service
 logs  Backup all outstanding logical logs
 verify Run archecker verification on the latest backup 

The default infx BAR manager definition maps the backup types to ontape commands.

 infx command  ontape command
 infx backup type=dbs  ontape -s -v -d
 infx backup type=ext  /infx/local/script/sample/ext-backup.sh
 infx backup type=fake  ontape -s -F -:L 0 -t /dev/null
 infx backup type=hot  ontape -s -F -L 0 -t STDIO
 infx backup type=logs  ontape -a -d
 infx backup type=verify /infx/local/scripts/sample/ontape-verify

alias

infx includes default alias definitions to make running backups from the command line easier.

 alias  expanded command
 infx L0  infx backup type=dbs level=0
 infx L1  infx backup type=dbs level=1
 infx L2  infx backup type=dbs level=2
 infx logs  infx backup type=logs

forking backups

infx automatically forks all backup commands into the background, and detaches them from the terminal that started them. This means that if you log out or lose your network connection, the backup continues.

You can manually fork the infx command into background (adding a "&" to the command line), in that case, you can use the follow service to track the progress of the service.

Example, follow the execution of the backup-dbs service.

infx follow service=backup-dbs

infx follow s=backup-dbs

Example, follow the execution of the most recently started service.

infx follow

dbs backup

The dbs function of the backup service backs up the storage spaces, and can also be used to set logging modes of databases in the instance.

By default the backups are stored in the instance backup directory (/infx/inst/${inst}/backup/db). This is set in the ONCONFIG TAPEDEV parameter, but can also be overridden on the command line.

 parameter description
 level Level of backup, 0=fiull, 1=everything since last level 0, 2=everything since last level 1
 tapedev Alternate directory for ontape backup output, this directory must already exist
 ansi Change database logging mode to ANSI logging. Specify a comma separated list of database names
 buf Change database logging mode to bufered logging. Specify a comma separated list of database names
 unbuf Change database logging mode to unbufferd logging. Specify a comma separated list of database names
 nolog Change database logging mode to non-logged. Specify a comma separated list of database names

examples

 command description
 infx backup type=dbs buf=db1 Full backup to the default location. After the backup, db1 will be set to buffered logging mode.
 infx backup type=dbs level=1 Performs a level 1 backup of the storage spaces, to the default location
 infx backup tapedev=/tmp/backup Perform a level 0 backup, the backup will be written to the /tmp/backup directory
 infx L0 buf=db1 Performs a backup based on the L0 alias definition, then set db1 to buffered logging mode

When you use an alias definition, additional parameters are passed through to the command. If you specify a parameter on the command line that is already part of the alias definition, the command line value takes precedence.

logs backup

The logs function of the backup service is used to back up all outstanding logs. That is, logical logs that are used but have not been backed up. It does not back up the current log.

Example, back up all outstanding logical logs.

infx logs

The location of the logical log backup is determined by the ONCONFIG LTAPEDEV parameter, and by default is /infx/inst/${inst}/backup/logs.

The easiest way to configure automatic back up of the logical logs is by using the ALARMPROGRAM setting in the ONCONFIG file. Different events and conditions in the instance will trigger this command. One of the triggers is a logical log filling up, and the Informix supplied script already has hooks in it for your backup command.

To convert the standard alarmprogram.sh that ships with Informix, make the following changes.
  1. Set BACKUPLOGS=Y (around line 30)
  2. Set BACKUP_CMD="/infx/scripts/infx backup-logs fork=no" (around line 61)
Now, when a logical log fills up, Informix will call the infx backup service and back up the logical logs.

external backup

The ext function of the backup service is used to run external backups. External backups are done by a utility outside of Informix. To support this back up type, Informix allows you to block the database server, holding updates while the external utilitie makes a physical copy of the database chunks.

The external backup service will block the instance, run your external backup command, and then unblock the instance. infx also captures the output into the backup service log.

The command that does the external backup can be any command or script. It can use the storage itself to copy or clone the data, or any other utility. Just remember that you cannot update the database while the external backup is running.

Example script that uses tar to make a backup of the chunk files.

#!/bin/ksh

cd /infx/inst/$INFORMIXSERVER/chks
tar cvf - . | gzip -c >/scratch/infx/$INFORMIXSERVER.tar.gz

fake backup

A fake backup does not actually do a backup, but can be used to set flags within the instance, but a real backup must be performed shortly after.

Examples
  1. Change the logging mode of the database
  2. Change RAW type tables to standard
When you take these actions, your database is not recoverable until you have completed a real level 0 backup.

For example, here is a sequence that benefits from using the fake backup.
  1. Create a database
  2. Load data into raw tables
  3. Run a fake backup, set the tables to standard
  4. Create indices and other database objects
  5. Run a real backup 
The fake backup is not recorded in the system. This means if you run a level 1 backup, it backs up pages changed since the last REAL level 0.

hot backup

The hot backup function of the backup service is used to copy the data from one instance to another of the same format. You would not normally execute this command directly, but use the hot copy function of the restore service to copy one instance to another.

The hot backup is executed as a "fake" backup, and has no impact on subsequent level 1 backups.

backup verification

The verify backup function of the backup service is used to run the archecker utility and verify the latest backup.. For ontape backup to directories verification is performed using the infx script /infx/local/script/sample/ontape-verify.

Example script that performs archecker verification:

#!/bin/sh
#
#       ontape-verify.sh
#
#       Verify the last backup using archecker
#

FLAG=$INFX_FLAG
if [ -z "$FLAG" ] ; then
        FLAG=-t
fi

rm -f /tmp/ac_msg.log
archecker ${FLAG}dvs
passed=`grep "Archive Validation PASSED." /tmp/ac_msg.log | wc -l`
if [ $passed -eq 1 ] ; then
        echo `date` infx_info archive validation passed
else
        echo `date` infx_error archive validation failed
fi