Sunday, February 23, 2014

Perform table restore in Informix

This article introduces how to perform table level restore in IBM Informix with the help of Archecker utility.
Informix Dynamic Server V10.0 (IDS) provides you with the ability to easily extract data in tables of databases from a 0-level backup to a specified point in time. The extracted data can be loaded in internal, external tables or ASCII files. 

1. Archecker utility

The archecker utility uses a configuration file to set certain parameters. Set the AC_CONFIG environment variable to the full pathname of the archecker configuration file. By default, the AC_CONFIG environment variable is set to $INFORMIXDIR/etc/ac_config.std. If you set AC_CONFIG to a user-defined file, you must specify the entire path including the filename. The schema command file is use to specify the source and destination tables and to define the table schema.
The archecker utility uses a schema command file to specify the following:

  • Source tablels
  • Destination tables
  • Table schemas
  • Databases
  • External tables
  • Point in time the table is restored to

2. Table restore


Restore a specific table or set of tables that have previously been backed up with ON-Bar or ontape.
When reading the command file, archecker determines whether to perform a physical restore only or a physical restore followed by a logical restore. By default, archecker performs a physical and logical restore. If you use the WITH NO LOG clause, archecker does not perform a logical restore.
After a physical restore, logical recovery can further restore tables to a user-specified point in time. To do this, the archecker utility reads backed-up logical logs, converts them to SQL statements, and then replays these statements to restore data.

3. Archecker command


>>-archecker---------------------------------------------------->

>--+-+-+- -b-+--| Table-level restore |--+-----+-+--+-----+--+-----+-+-><
   | | '- -t-'                           '- -d-' |  '- -v-'  '- -s-' |   
   | +- -D---------------------------------------+                   |   
   | '- -i---------------------------------------'                   |   
   +- -V-------------------------------------------------------------+   
   '- -version-------------------------------------------------------'   

Table-level restore

|--+------------------------------------------------+-----------|
   '- -X--+---------------------------------------+-'   
          +-+---------------+--+----------------+-+     
          | '- -f--cmd_file-'  '- -l--+-phys--+-' |     
          |                           +-stage-+   |     
          |                           '-apply-'   |     
          '- -D-----------------------------------'     


Element
Description
-b
Provides direct XBSA access for backups created with ON-Bar.
-d
Deletes previous archecker restore files, except the archecker message log.
For more information, see When to delete restore files.
-D
Deletes previous archecker restore files, except the archecker message log, and then exits.
The -D option can be used with the -X option to delete previous restore files plus any
table-level-restore working tables in the sysutilsdatabase.
For more information, see When to delete restore files.
-f cmdfile
Specifies that archecker use the command file specified by cmdfile.
option overrides the value of the AC_SCHEMA configuration parameter.
For more information, see Schema command file.
-i
Manually initializes the system.
-lphys,stage,apply
Specifies the level of logical restore:
phys
Starts a logical restore of the system, but stops after physical recovery is complete.
The backed up logical logs must be available.
stage
After physical recovery is complete, extracts the logical logs from the storage manager
and stages them in their corresponding tables, and starts the stager.
apply
Starts the applier. The applier takes the transactions stored in the stage tables and
converts them to SQL and replays the operations.
The default level of logical restore if -l is not listed is -lphys,stage,apply. You can
 specify any combination of the logical restore levels, separated with commas. Spaces
are not allowed between -l and levels.
For more information, see Manually control a logical restore.
-s
Prints a status message to the screen.
-t
Specifies ontape as the backup utility.
-v
Specifies verbose mode.
-X
Specifies a table-level restore.
-V
Displays IBM® Informix® version information.
-version
Displays additional version information about the build operation system, build number,
 and build date for IBM Informix.


4. An example to restore a table

Here we extract a table called customer from the most recent backup of dbspace and place the data in table customer.
Create a new command file to cmdfile1.cmd in directory ‘/Informix’ and edit thecommand file as follows:
database stores7;
create table customer
  (
    customer_num serial not null ,
    fname char(15),
    lname char(15),
    company char(20),
    address1 char(20),
    address2 char(20),
    city char(15),
    state char(2),
    zipcode char(5),
    phone char(18),
    primary key (customer_num)
  ) in datadbs;
insert into customer select * from customer;
Restore customer table with the command: archecker -bvs -f /informix/cmdfile1.cmd





No comments:

Post a Comment