GBase News

Focus on Database Software Products and Services, Committed to becoming the most trusted provider of database products for users.

GBase 8s Table-Level Recovery: Restore Dropped Tables with archecker

Published on 2026-11-27

Some of the most nerve-wracking moments in operations start with a single mis-executed SQL statement. A core table gets dropped or corrupted, a full database restore takes hours, and other business systems may be affected in the meantime.

GBase 8s ships with the archecker utility, whose core value is simple: recover only the tables affected by the incident — no need to restore the entire instance.

1. How It Works: Physical Restore + Logical Restore

archecker recovers data at the table level by extracting it from Level 0 archives (ontape/onbar backups) and logical logs, based on a specified source table and target table.

Recovery runs in two phases:

Physical restore: archecker scans the Level 0 archive for pages belonging to the target table, extracts rows one by one, and inserts them into the target table. Before recovery begins, it automatically disables constraints, indexes, and triggers associated with that table.

Logical restore: On top of the physical restore, archecker replays the backed-up logical logs to roll the table forward to a user-specified point in time. Logical restore uses two parallel processes: the stager scans logical log backups, filters out log records related to the target table, and stores them in a table; the applier converts those log records into SQL statements and executes them.

Key constraints for logical restore:

  • The database must be in logging mode.
  • The transactions to be recovered must already be present in backed-up logical logs (archecker does not read the current log).
  • If the target table is dropped, truncated, or altered during logical restore, recovery of that table stops.
  • Logical restore cannot be performed on external tables.

2. Two Key Files

archecker's behavior is defined by a configuration file, while the data to be recovered is defined by a schema command file.

1. Configuration File

Specified via the AC_CONFIG environment variable; defaults to $GBASEDBTDIR/etc/ac_config.std. In most cases you can use the default template without modification.

Key parameters:

  • AC_MSGPATH: Path to the archecker runtime log. Recovery warnings and errors are written here — check this first when troubleshooting.
  • AC_STORAGE: Directory for temporary files generated while archecker parses backups. Ensure sufficient disk space.
  • AC_VERBOSE: Log verbosity. 1 for detailed logs (useful for troubleshooting), 0 for concise logs.
  • AC_SCHEMA: Full path to the schema command file.

2. Schema Command File

This is the heart of recovery. It uses SQL-like statements to describe "where to take data from, where to put it, and to what point in time to recover." You can specify it with AC_SCHEMA or with the command-line option -f (-f takes precedence if both are used).

Supported statements include CREATE TABLE, DATABASE, INSERT INTO, RESTORE, and SET.

The schema command file specifies:

  • Source table
  • Target table
  • Table schema
  • Database
  • Recovery point in time
  • Other options

3. Typical Schema Command File Examples

The following examples cover the most common recovery scenarios in day-to-day operations and can be adapted directly.

Example 1: Simplest Schema Command File

Extract a table from the most recent Level 0 backup of dbspace1, place the data into test1:tlr, and recover to the end of the currently backed-up logical logs:

database test1;
create table tlr (
 a_serial serial,
 b_integer integer,
 c_char char,
 d_decimal decimal
) in dbspace1;
insert into tlr select * from tlr;
restore to current;

Example 2: Recover from a Previous Backup to a Specified Point in Time

Use logical logs to recover the table to '2003-01-01 01:01:01':

database test1;
create table tlr (
 a_serial serial,
 b_integer integer,
 c_char char,
 d_decimal decimal
) in dbspace1;
insert into tlr select * from tlr;
restore to '2003-01-01 01:01:01';

A key detail: when using point-in-time recovery, you must first set the GL_DATETIME environment variable so that the time format in the command file matches the system's parsing format. In addition, the point in time must fall within the coverage of backed-up logical logs.

$ export GL_DATETIME="%Y-%m-%d %H:%M:%S"

Example 3: Recover to a Different Table

Extract test1:tlr from backup and place the data into test1:tlr_dest (target table in dbspace2):

database test1;
create table tlr (
 a_serial serial,
 b_integer integer,
 c_char char(20),
 d_decimal decimal
) in dbspace1;
create table tlr_dest (
 a_serial serial,
 b_integer integer,
 c_char char(20),
 d_decimal decimal
) in dbspace2;
insert into tlr_dest select * from tlr;
restore to current;

Example 4: Extract a Subset of Columns

Extract only some columns from the source table and map them to different column names in the target table:

database test1;
create table tlr (
 a_serial serial,
 b_integer integer,
 c_char char(20),
 d_decimal decimal
) in dbspace1;
create table new_dest (
 X_char char(20),
 Y_decimal decimal,
 Z_name char(40)
) in dbspace2;
insert into new_dest (X_char, Y_decimal) select c_char, d_decimal from tlr;
restore to current;

Example 5: Use Data Filtering

Recover only rows that meet a condition. Note: filters can be applied only to pure physical restore (adding the WITH NO LOG clause to the RESTORE statement performs physical restore only).

database test1;
create table tlr (
 a_serial serial,
 b_integer integer,
 c_char char(20),
 d_decimal decimal
) in dbspace1;
insert into tlr
select * from tlr
where c_char matches 'john*'
and d_decimal is NOT NULL
and b_integer > 100;
restore to current with nolog;

Example 6: Recover Multiple Tables at Once

Write multiple INSERT statements in one command file — the archive and logical logs are scanned only once, which is more efficient:

database test1;
create table tlr_1 ( id int ) in dbspace1;
create table tlr_1_dest ( id int );
create table tlr_2 ( id int ) in dbspace1;
create table tlr_2_dest ( id int );
insert into tlr_1_dest select * from tlr_1;
insert into tlr_2_dest select * from tlr_2;
restore to current;

4. Command-Line Options at a Glance

archecker requires a configuration file and a schema command file. Common options:

-t — Specify ontape as the backup tool (use -b for onbar backups, which provides direct XBSA access).

-X — Specify table-level recovery.

-s — Output status messages to the screen.

-v — Verbose mode.

-f — Specify the schema command file (overrides AC_SCHEMA).

-d — Clear work files and sysutils work tables from the previous recovery before starting a new one.

-l — Specify the logical recovery level; any combination of levels can be specified.

-D — Clear recovery files only and exit; combined with -X, also cleans sysutils work tables.

Typical commands:

archecker -tvs -f t1.cmd          # Full recovery based on ontape backup
archecker -bvs -f t1.cmd          # Full recovery based on onbar backup
archecker -tvs -f t1.cmd -lphys   # Physical restore only
archecker -tvs -f t1.cmd -lstage  # After physical restore, extract logical log records into the table
archecker -tvs -f t1.cmd -lapply  # Extract transactions from the table, convert to SQL, and replay
archecker -DX                     # Clean up work files and sysutils tables from the previous recovery

5. Hands-On: Recovering a Dropped Table End to End

Step 1: Create the table and insert test data

$ dbaccess gbasedb -
> create table t1 (id char(10), name char(10), info char(10));
Table created.
> insert into t1 values('ndty','gbase8s','gbase350');
1 row inserted.

Step 2: Perform a Level 0 backup

$ ontape -s -L 0

Step 3: Simulate accidental deletion

$ dbaccess gbasedb -
> drop table t1;

Step 4: Write the schema command file t1.cmd

database gbasedb;
create table t1 (id char(10), name char(10), info char(10)) in dbspace1;
insert into t1 select * from t1;
restore to current;

Step 5: Run recovery

$ archecker -tvs -f t1.cmd

Step 6: Verify the recovered data

$ dbaccess gbasedb -
> select * from t1;

Table t1 is now fully recovered.

Conclusion

Remember three things:

  • First, after an accidental deletion, back up the current logical logs before starting recovery.
  • Second, archecker can only recover tables that have backups — without a Level 0 backup, nothing else matters.
  • Third, before completing recovery in production, recover to a temporary table first and compare data accuracy; switch over only after confirming correctness.

FAQ

What can archecker do, and why not a full restore?

Restores only affected tables from level-0 archives and logical logs—no full instance restore.

What are the two phases? 

Physical recovery scans and inserts target-table pages (auto-disabling constraints/indexes/triggers); logical recovery replays logs via stager (scan/filter) and applier (convert to SQL).

Key constraints? 

Logging mode; transaction in backed-up logs; no drop/truncate/alter during recovery; no external tables.