IIAS 1.0.21 - Columnar Incremental Schema Backup and Restore Feature - 1
IIAS 1.0.21 - Columnar Incremental Schema Backup and Restore Feature - 1
Restore Feature
Version: 1.0.21
Terminology
This document discusses both cumulative and delta incremental schema backup. A reference to an
‘incremental backup’ in the document is assumed, unless specifically mentioned, to be either a
cumulative or delta incremental backup.
Introduction
This feature provides the ability to do cumulative incremental or delta incremental backup of a schema
followed by full restore of the schema or table(s) within the schema.
This feature is recommended to be tested by customers in a test environment. Poor performance may
be experienced during schema backup. The work is ongoing to address the problem. Once a fix has been
validated, it will be available via a special build based on 1.0.21.
In order to take advantage of this new feature you will need the following:
A new schema created with the “ENABLE ROW MODIFICATION TRACKING” attribute. Permanent
organized by column tables created within this schema will be enabled for row modification
tracking, meaning they will contain 3 additional hidden columns for tracking incremental
modifications to the rows between two backups.
Use of new options provided on the db_backup and db_restore commands for schema
incremental backup.
Schema level backup of a schema enabled for row modification tracking will allow read access as well as
concurrent insert, update, and delete. This is an improvement over schema backup capability, which
supports only read access.
# Insert some more data, then capture a cumulative incremental schema backup
INSERT INTO S1.T1 values (2)
db_backup -type inc -schema S1 -compress lz4 -format binary -path p1
>--+-schema-name------------------------------------+----------->
+-AUTHORIZATION--authorization-name--------------+
'-schema-name--AUTHORIZATION--authorization-name-'
>--+---------------------------+-------------------------------->
'-DATA CAPTURE--+-NONE----+-'
'-CHANGES-'
>--+----------------------------------+------------------------->
'-ENABLE ROW MODIFICATION TRACKING-'
>--+--------------------------+------------------------------+-><
| .----------------------. |
| V | |
'---schema-SQL-statement-+-'
Notice it is not the default and therefore to take advantage of incremental schema backup and restore
explicit schema creation with the new attribute is necessary.
Catalog changes
A new column in SYSCAT.SCHEMATA called ROWMODIFICATIONTRACKING will indicate whether the
schema is enabled for row modification tracking or not with a value of ‘N’ or ‘Y’.
Only permanent columnar tables created in a schema enabled for row modification tracking will be
enabled for row modification tracking. The following tables will not be enabled for row modification and
thus will not contain the extra 3 columns:
Temporary tables
External tables
Materialized query tables
Tables not in the list above which are also not organized by column (i.e. organized by row, insert
time, dimensions-clause, etc.)
The above tables can be created in a schema enabled for row modification tracking, but there are couple
caveats to be aware of:
You can see the extra columns for your table when doing a describe of the table:
db2 "DESCRIBE TABLE S1.T1"
4 record(s) selected.
Since they are implicitly hidden columns with values internally generated you will not see them when
doing a select * from the table for example, and you do not need to specify them when doing an insert,
update or delete statement. Attempting to modify the columns (insert/update/delete/alter) will either
be ignored or result in an error.
db_backup
Schema-level backup can be performed by passing the schema name to the db_backup utility using -
schema <schema_name> option. If this option is omitted, the tool invokes db2 utilities to backup the
entire database.
-type onl|inc|del
onl – Full online backup
inc – Online Cumulative incremental backup
del – Online Delta incremental backup(also known as a differential backup)
-path PATH
Target directory for backup image. Use ( ) or (,) or ( ,) to separate multi-path.
-schema SCHEMANAME
Schema to be backed up.
**Note** The default format changed from TEXT prior to 1.0.20 to BINARY in 1.0.21
db_restore
Schema level restore can be performed by passing the schema name to the db_restore utility using -
schema <schema_name> option. To restore a single or multiple tables, -table or -tablefile options can
also be used respectively.
-type frh|inc|del
frh – Restore from a full backup
inc – Full restore from a cumulative incremental backup
del – Full restore from a delta incremental backup.
-path PATH
Path to the directory where backup exists. Use ( ) or (,) or ( ,) to separate multi-path
-timestamp TIMESTAMP
Timestamp of the backup.
-schema SCHEMA
Schema to be restored.
-table TABLE
Table to be restored.
-tablefile FILEPATH
Full path to the file with tables to be restored.
-drop-existing
Drop existing schema and its table/non-table objects before restore.
Using “-drop-existing”
Note some schema objects can not be dropped via db_restore with the -drop-existing option. If you
receive a failure during restore to drop any objects you will need to drop the objects manually and re-
issue the restore.
Using “-path”
Each full online schema backup and incremental backup images can be stored in separate paths and
even in multiple paths for each backup. If you do not change the location of the backup images between
the backup and restore then restore will be able to find all the necessarily files. For any backup images
which are moved prior to restore you will need to provide all paths for those images on restore.
Migration considerations
Users may alter their schema to enable row modification tracking, however this does not modify any of
the tables in the schema to enable row modification tracking. Only new tables created in the schema
will be enabled for row modification tracking. If you alter your schema to enable row modification
tracking, you will need to recreate all your columnar tables in the schema before a schema backup will
be possible. Recreating the tables can be done through any means, for example using
ADMIN_MOVE_TABLE, or CREATE TABLE … AS … WITH DATA (select * from one table into a new table in
the same schema).
.--------------------------------------------------------------.
V |
>----+-DATA CAPTURE--+-NONE----+--------------------------------+-+-><
| '-CHANGES-' |
+-ENABLE ROW MODIFICATION TRACKING-------------------------+
Please note that values stored in 3 new columns will require additional space, and therefore a table that
is enabled for row modification tracking will contain more pages than exactly same table that is not.
DB2 Limitations
db2load into a table enabled for row modification tracking which also contains a user defined
identity column will fail.
db2load into a table enabled for row modification tracking which is also defined as DISTRIBUTE
BY RANDOM will fail.
Exception tables for db2load and INGEST cannot be columnar and thus the recommended
approach to use an exception table for db2load or INGEST into a table enabled for row
modification tracking is to create a row organized table in another schema (different schema
because the row organized table will cause incremental schema backup to fail). In addition to
that, the exception table must have a similar definition including the hidden columns defined for
row modification tracking except the SYSROWID can not be an identity column since these are
not supported in exception tables.
o For example:
CREATE SCHEMA S1 ENABLE ROW MODIFICATION TRACKING
CREATE SCHEMA S2
CREATE TABLE S1.T1 (C1 INT)
CREATE TABLE S2.LOADEXTBL (SYSROWID BIGINT NOT NULL, CREATEXID BIGINT
NOT NULL, DELETEXID BIGINT NOT NULL, C1 INT)
LOAD FROM <file> OF DEL INSERT INTO S1.T1 FOR EXCEPTION S2.LOADEXTBL
The maximum number of user defined columns in a table enabled for row modification tracking
is reduced to 1009.
IMPORT using CREATE or REPLACE_CREATE options into a table enabled for row modification
tracking may fail.
ADMIN_COPY_SCHEMA with a copymode of ‘COPY’ or ‘COPYNO’ is not supported when the
source schema is enabled for row modification tracking. If it is used with copymode of ‘DDL’ the
target schema will not be created with row modification tracking enabled (regardless of
whether the source is or not).
No support for alter of a table enabled for row modification tracking to be a materialized query
table.
None of the 3 new hidden columns (SYSROWID, CREATEXID, DELETEXID) are supported within
the distribution key of the table (i.e. not allowed in the DISTRIBUTE BY HASH column list).
No support for Q Replication of tables in schemas enabled for row modification tracking. Do not
subscribe these schemas/tables for replication.
No support for db2move if the source or target is a table in a schema enabled for row
modification tracking.
None of the 3 new hidden columns can be included as part of an index key or in an enforced
constraint. Both CREATEXID and DELETEXID cannot be included as part of an unenforced
constraint.
No support for System-period temporal tables or Bitemporal-period temporal tables with row
modification tracking enabled, however Application-period temporal table will support row
modification tracking.
No support for CREATE VIEW … WITH ROW MOVEMENT with row modification tracking enabled.
db_backup limitations
General limitations schema backup (any schema):
Incremental schema backup (-type inc and -type del) is only supported for new schemas and
tables (tables created in a new schema which is enabled for row modification tracking). No
support for migration of existing schemas or tables to be enabled for row modification tracking.
Concurrent Select/Insert/Update/Delete operations will be supported against the row
modification tracking schema being backed up. Some DDL will remain blocked. Full access to
other schemas not under backup will remain unchanged (i.e. no restrictions).
No multi-schema backup support for schemas enabled for row modification tracking. If any one
of the schemas specified in a multi-schema backup are enabled for row modification tracking,
the backup will fail.
Backup of a schema enabled for row modification tracking will fail if Row and column access
control (RCAC) is in effect for any data inside the schema.
Can only backup entire schema and not a single or select number of tables.
Cannot backup a schema that contains a period (.) in its name.
The Db2 LIST HISTORY command will not show schema level backups or restores. Use
db_backup/db_restore -history instead.
Point in time roll forward is not supported.
Label-based access control (LBAC) information is not supported on columnar tables and not
scoped by a schema so this information will not be included in a schema backup.
Typed tables and views not supported.
JAR objects stored in the database (via SQLJ.INSTALL_JAR) for use in procedures will not be
captured by the schema backup. This is no different than the behavior for any other external
procedure like a C routine. It is recommended customers save and restore these themselves.
Cannot backup a schema that has tables with single/double quotes in the name.
If schema specified via -schema option has double quotes in the name or is case-sensitive, it
must be enclosed with single and double quotes (e.g. Schema”1” must be specified as -schema
‘”Schema”1””’)
If your schema contains any of the following, then schema backup (full or incremental) will fail:
If any of the following DDL was issued between the previous schema backup and the current schema
incremental backup, the incremental backup will fail (the response here is to instead run a full
schema backup):
DROP/RENAME TABLESPACE. Note this applies to any tablespace and not just tablespaces
used by a given schema to backup.
RENAME TABLE
DROP SCHEMA
ALTER TABLE … ADD FOREIGN KEY
The following index operations will not be captured by an incremental backup. Indexes will be
captured in a full backup, but any index change will not be captured by an incremental (it will be
ignored by incremental backup and thus will not be part of the schema after restore):
CREATE/DROP/ALTER/RENAME INDEX
If any of the following DDL was issued between the previous schema backup and the current schema
incremental backup it will result in a full backup of the table referenced in the DDL (other tables in
the schema will be unaffected, i.e. only incremental changes captured):
CREATE TABLE
TRUNCATE TABLE
LOAD using REPLACE option
IMPORT using REPLACE option
ALTER TABLE ... ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE
Special considerations for tablespace restore and rollforward when used in conjunction with schema
backup and restore. It is recommended not to mix these types of backup and restore since some
inconsistencies could arise, for example:
Currently S1.T1 has rows with values 1 and 3. However, if the user does a restore of the final
DELTA schema backup captured above S1.T1 would have rows with values 1, 2, and 3. Restore of
the final cumulative incremental schema backup would result in S1.T1 having rows with values 1
and 3.
It is not recommended to mix these types of backup and restore. Restoring a database level image
taken at a timestamp invalidates all schema level backup images taken after that timestamp.
Schema backup does not contain information about db-level objects (like TABLESPACE) and schema
restore does not ensure they are re-created if not present. In addition to that, database restore and
rollforward will overwrite (put back in time) the history table IBM_SAILFISH.GRANULAR_BACKUP.
See “History table considerations for full database restore” section below.
db_restore limitations
General limitations:
Concurrent read/write access to the schema or table undergoing restore is not blocked. See
section “Concurrent access to the schema during db_restore below.
Cannot restore a single schema or table(s) from a database-level backup.
Cannot restore a database from a schema-level backup.
Cannot restore a schema with a leading space in the name.
Cannot restore a table with a leading space in the name of primary key.
Table names specified via -table option are case-insensitive
If table specified via -table option is case-sensitive, it must be enclosed with single and double
quotes (e.g. Table1 must be specified as -table ‘”Table1”’)
Table names specified in file via -tablefile option are case sensitive
It is highly recommended users ensure no concurrent access is allowed during restore either via
application control, or via QUIESCE DATABASE IMMEDIATE prior to schema or table level restore. After
successful restore access can be resumed via UNQUIESCE DATABASE command. Please consult
documentation for QUIESCE DATABASE IMMEDIATE operation prior to use – it will force all active
connections for all schemas in the database and prevent new connections until UNQUIESCE DATABASE.
While a database is quiesced ap issues may report Major alert “351: Database availability issue” until
the database is unquiesced. This is expected behavior. It is possible to disable this alert via console
config update. Please note that when the issue is reported, console may not be able to detect that
database is available after UNQUIESCE until all “351” events are deleted.