> For the complete documentation index, see [llms.txt](https://documentation.atempo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/administration-guide/backup/db2.md). Agents can also search and read this documentation through its [MCP server](https://documentation.atempo.com/~gitbook/mcp).

# DB2

## Backing Up DB2 with Tina

This page explains how to protect an IBM DB2 instance using **Tina for DB2**.

Tina for DB2 supports two modes:

* **GUI mode**. You browse DB2 objects in Restore & Archive Manager.
* **Command mode**. DB2 natively runs `BACKUP` / `RESTORE` commands with a Tina library.

### About

Tina for DB2 protects DB2 databases and archived logs.

It supports:

* **Full backups**.
* **Incremental backups** (log-based, depending on DB2 mode and configuration).
* **Online** and **offline** backups.
* Restore with rollforward when archived logs are available.

{% hint style="info" %}
Online backup requires DB2 to have **archive logging** enabled.\
If archive logging is not enabled, Tina falls back to **offline** backups.
{% endhint %}

### Create the Agent

You create **one Tina DB2 application or configuration per DB2 instance**.

{% tabs %}
{% tab title="GUI Mode" %}

#### Prerequisites

* Install a Tina agent on the DB2 host.\
  See [Installing the Tina Agent.](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/administration-guide/deployment/installing-tina-agent.md)
* Check the supported versions in the [Compatibility Guide.](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/version-information/compatibility-guide.md)
* For online backups, enable archive logging on the database.
  * Pre-DB2 8.2 compatibility syntax:
    * `logretain=RECOVERY`
    * `userexit=OFF`
  * DB2 8.2+ syntax:
    * `logarchmeth1=LOGRETAIN` and `logarchmeth2=OFF`, or
    * `logarchmeth1=DISK:<path>`

{% hint style="warning" %}
After switching a database to archive logging, run **one full offline backup** first.\
DB2 may require this to clear the "backup pending" state.
{% endhint %}

#### OS Library Path (Uniclox)

Before starting the Tina daemon, make sure the DB2 libraries can be loaded:

* **AIX**: add `<DB2_installation_directory>/lib` to `LIBPATH`.
* **Linux/Solaris**: add `<DB2_installation_directory>/lib` to `LD_LIBRARY_PATH`.

`lib` may be `lib32` or `lib64` depending on your Tina build.

#### Create and Activate the Application

{% stepper %}
{% step %}
**Open the Application Creation Wizard**

In the Web Administration console:

1. Go to **Platforms → Applications**
2. Click **New Application**
   {% endstep %}

{% step %}
**Set the Main Parameters**

Set:

* **Host**: the machine running the DB2 instance
* **Application Type**: DB2
* **Application Version**: your DB2 version
* **Application Name**: a unique name (it becomes the backup folder name)
  {% endstep %}

{% step %}
**Set the Users**

Set:

* **Owner**: the OS user who runs the backups (`DOMAIN\User` on Windows)
* **Access User**: the DB2 user used to connect and enumerate databases

Make sure both users exist in Tina and have the appropriate permissions.
{% endstep %}

{% step %}
**Set the Tina DB2 Library Path**

Set the mandatory `TINA_APP_LIB_PATH` variable.

Examples:

* Windows: `libtina_db2_10.dll`
* Linux: `libtina_db2_10.so`
* AIX: `libtina_db2_10.a`

Choose the library matching your DB2 major version.
{% endstep %}

{% step %}
**Finish and Activate**

1. Check the summary
2. Click **Finish**
3. In the Applications list, select it and click **Activate Application**
   {% endstep %}
   {% endstepper %}

#### Validate the Connection (recommended)

Open Restore Manager on the application.

If the instance and database nodes open without errors, the configuration is correct.
{% endtab %}

{% tab title="Command Mode" %}

#### What You Configure

Command mode uses:

* the Tina provider library: `libtina_db2vp_<db2_major>.{so|dll}`
* a `tn_db2.conf` configuration file on the DB2 host
* a **Tina** archive folder to store backups (optionally a second one for logs)

#### Prerequisites

* Install a Tina agent on the DB2 host.\
  See [Installing the Tina Agent](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/administration-guide/deployment/installing-tina-agent.md).
* DB2 must be installed and running.
* The DB2 instance user must have Tina archive rights.

#### Create the Archive Folder

In the Web Administration console:

1. go to **Data Management → Archive Folders**
2. click **New Archive Folder**
3. select **DB2** as the folder type
4. select the DB2 platform host
5. set the DB2 information:
   * Windows: DB2 installation directory (if the default is incorrect)
   * Unix: DB2 instance administration name

This creates a skeleton `tn_db2.conf` on the DB2 host.

#### Make the Configuration Instance-Specific (recommended)

If you back up several DB2 instances, duplicate and rename the file:

* `tn_db2_<DB2INSTANCE>.conf`

The `<DB2INSTANCE>` part is **case-sensitive**.

#### Minimum `tn_db2.conf` Variables

Set at minimum:

* `TINA_HOME`
* `TINA_DB2_FOLDER` (archive folder name)
* `TINA_DB2_USER` (DB2 instance administrator used as the operator)

Optional but common:

* `TINA_DB2_CATALOG` (multi-catalog environments)
* `TINA_DB2_EVENT_DIR` (where the library events are written)
* `TINA_SERVICE_TCP_NUM` / `TINA_SERVICE_UDP_NUM` (if using non-default ports)

#### Log Archiving (optional, userexit)

If you want to archive transaction logs via DB2 `userexit`:

* create a separate archive folder (optional)
* add `TINA_DB2_FOLDER_LOG` (and `TINA_DB2_CATALOG_LOG` if needed)
* set the following DB2 database parameters:
  * `userexit=ON`
  * `logretain=OFF` (legacy syntax)

DB2 8.2+ typically uses `logarchmeth1` / `logarchmeth2` instead.
{% endtab %}
{% endtabs %}

### Backing Up DB2

{% tabs %}
{% tab title="GUI Mode" %}

#### Full vs Incremental

Tina supports:

* **Full**: backs up databases and logs.
* **Incremental**:
  * if the database supports online backup, it backs up **only the archived logs**
  * otherwise, Tina performs a **full** backup even if you requested incremental

If log files are missing during an incremental, Tina also falls back to a full backup.

#### Cleaning Up Obsolete Logs

Archived logs are removed from `LOGPATH` only during incremental backups.

During the first incremental after a full backup, logs older than the **first active log** of the full backup are obsolete.

#### Mirrored Logs

If Tina cannot find a log file, it can use the mirror copy of the log.

The backup completes, but Tina raises an alarm.

#### Online vs Offline

* **Online backup** keeps the database available. It requires archive logging.
* **Offline backup** forces all users to disconnect. It is generally faster.

#### Configure Automatic Backups

Configure these standard Tina objects:

* **Media Pool**
* **Backup Strategy**
* **Backup Selection**

{% hint style="warning" %}
Do not use `tar` or `cpio` formats for DB2 GUI backups.\
They can cause restore issues with the logs.
{% endhint %}

#### Parallel Backups (optional)

Parallel backup splits a job into several streams.

Key rules:

* Enable parallelization on **database selections** only.
* Set the **Parallelism Index** strategy setting to a value `> 1`.
* Windows does not support parallel DB2 backup in GUI mode.
  {% endtab %}

{% tab title="Command Mode" %}

#### Run a Database Backup from the DB2 CLP

DB2 runs the backup.\
You point it to the Tina provider library.

Example:

```
db2 backup db SAMPLE online load /usr/tina/Lib/libtina_db2vp_10.so
```

#### Incremental and Delta Backups

Enable DB2 change tracking:

```
db2 update database configuration for <database> using trackmod on
```

#### Archiving Log Files

Depending on your DB2 logging configuration:

* automated mode archives logs via `userexit`
* manual mode uses:

```
db2 archive log for database <database>
```

{% endtab %}
{% endtabs %}

### Environment Variables

Set the variables either:

* during application creation (GUI mode)
* or in the DB2 host configuration (`tn_db2.conf`, command mode)

{% tabs %}
{% tab title="GUI Mode (DB2 Application)" %}

#### Required

* `TINA_APP_LIB_PATH`\
  Path to the Tina GUI library for DB2.\
  Example: `libtina_db2_10.so` / `libtina_db2_10.dll`.

#### Performance and Behavior

* `TINA_DB2_BUFFER_NUMBER` (default: `2`)\
  Number of DB2 buffers used for backup and restore.
* `TINA_DB2_BUFFER_SIZE` (default: `16`)\
  Buffer size in 4 KB pages.\
  Use the same value for backup and restore.
* `TINA_DB2_COMPRESS` (default: `no`)\
  Enables backup compression for DB2.
* `TINA_DB2_OPEN_TIMEOUT_BACKUP` (default: `120`)\
  Connection timeout for backup.
* `TINA_DB2_OPEN_TIMEOUT_RESTORE` (default: `600`)\
  Connection timeout for restore.

#### Restore and Redirection (used during restore workflows)

This is documented on the restore page:

* `TINA_DB2_OVERFLOW_LP`
* `TINA_DB2_TARGET_DB`
* `TINA_DB2_TARGET_PATH`
* `TINA_DB2_NEWLOGPATH`
* `TINA_DB2_REDIRECT_PATH`
* `TINA_DB2_CONTAINER_CFG`
* `TINA_DB2_ROLLFORWARD`
* `TINA_DB2_DUMP_TO_DISK`
  {% endtab %}

{% tab title="Command Mode (tn\_db2.conf)" %}
These variables drive the Tina provider library and the DB2 user exit script.

#### Core

* `TINA_HOME` (required, set by the installation)
* `TINA_DB2_FOLDER` (required)
* `TINA_DB2_USER` (required)

#### Multi-Catalog and Security (optional)

* `TINA_DB2_CATALOG`
* `TINA_DB2_SECURE_SESSION_ID` (required to restore protected data)

#### Troubleshooting and Tuning (optional)

* `TINA_DB2_EVENT_DIR`
* `TINA_DB2_TRACE_DEBUG`
* `TINA_DB2_SHM_SIZE`
* `TINA_OPEN_PIPE_TIMEOUT_BACKUP`
* `TINA_OPEN_PIPE_TIMEOUT_RESTORE`

#### Log-Specific (optional)

If you store logs in a different archive folder:

* `TINA_DB2_FOLDER_LOG`
* `TINA_DB2_CATALOG_LOG`
  {% endtab %}
  {% endtabs %}

### Backup

This topic describes the types of backup performed by Tina, as well as the following\
information:<br>

* [<mark style="color:blue;">Backing Up a DB2 Instance</mark>](#backing-up-a-db2-instance)
* [<mark style="color:blue;">Configuring Backups</mark>](#configuring-backups)
* [<mark style="color:blue;">Parallel Backup</mark>](#parallel-backup)

#### Backing Up a DB2 Instance

Tina supports two backup types: full backups and\
incremental backups.

**Full Backup**

A full backup backs up the databases as well as the archived\
log files. During each full backup, a new instance of the database meta-file is created in the meta-tree of the Restore and Archive interface.\
To perform online backups, the DB2 log retain parameter must be set to RECOVERY.

Otherwise, Tina performs an offline backup.\
To perform offline backups, all users must be disconnected from the database, otherwise the backup fails.\
If an error occurs during a full backup, the corresponding backup instance will be fuzzy and a question mark "?" will be added to its attributes. In addition, a minor alarm will be attached to the backup job and to the DB2 application in the Web Administration console.

**Full or Incremental Backup?**

Backups generate obsolete log files that are only deleted during incremental backups.\
Incremental backups should be scheduled for DB2 databases\
that support online backup.

**Log File Mirroring**

If a log file cannot be found during a backup, Tina looks for its copy in the\
mirror directory and completes the backup. It then reports the disappearance of the\
primary log file via an alarm.

#### Configuring Backups

You must configure Tina to automatically back up your\
databases.

<table><thead><tr><th width="216.33331298828125">Object</th><th>Description</th></tr></thead><tbody><tr><td><strong>Media Pool</strong></td><td>See the <a href="https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/tina-4.9.5-documentation.md">Tina Administration Documentation</a> to create or edit a media pool.</td></tr><tr><td><strong>Backup Strategy</strong></td><td>See the<a href="https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/tina-4.9.5-documentation.md"> Tina Administration Documentation t</a>o create or edit a backup strategy. The tar and cpio formats are not allowed for DB2 backups in GUI mode, due to errors that can occur when restoring log files.</td></tr><tr><td><strong>Backup Selection</strong></td><td><p>By default, a backup selection is automatically set on the root meta-directory of the file tree so that all databases are backed up. This default backup selection has the following characteristics:</p><ul><li>It is associated with all backup strategies.</li><li>No filter is set.</li><li>No time slot is excluded.</li><li>The data format is compressed and unencrypted. If you want to modify this default backup selection or create backup selections, see the Tina Administration Documentation.</li></ul></td></tr></tbody></table>

#### Parallel Backup

Tina's Parallel Backup feature improves system performance by letting you split backup jobs into several processes that run simultaneously.

> **Note**: Parallel backup on Windows for DB2 is not available.

Parallelization is enabled at the backup selection level. During backup, for each new backup selection declared as parallelized, Tina generates an additional backup process. The maximum number of simultaneous streams is defined in the strategy (Parallelism Index). You can run as many simultaneous streams as there are available drives.

**Configure Parallel Backups**

1. Set backup selections on the databases you want to parallelize, and check the Parallelized box in the Properties tab.

   > **Note**: Parallelization is only available at the database level. Do not set backup selections on any other type of meta-object.
2. In the Advanced tab of the backup strategy, enter a Parallelism Index equal to the number of drives. This index must be greater than 1.

See [Restoring DB2](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/administration-guide/restore/db2.md) for restore scenarios and details on rollforward.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/administration-guide/backup/db2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
