> 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/restore/db2.md). Agents can also search and read this documentation through its [MCP server](https://documentation.atempo.com/~gitbook/mcp).

# DB2

## Restore DB2 with Tina

This page covers DB2 restore and recovery workflows with **Tina for DB2**.

Tina for DB2 supports:

* **Graphical Mode** restores from Restore & Archive Manager.
* **Command Mode** restores using native DB2 `RESTORE` + `ROLLFORWARD`.

### Prerequisites

#### Disconnect users

DB2 restores are **cold restores**.

Disconnect all client sessions from the database before restoring.

#### Rollforward requires archived logs

Rollforward recovery requires:

* a database backup
* the archived transaction logs created after that backup

If the logs are not available, you only get **version recovery**.

### Graphical Mode restore scenarios

#### Restore a lost database

{% stepper %}
{% step %}
**Browse to the correct backup version**

In Restore & Archive Manager, open the meta-directory for the desired backup version.
{% endstep %}

{% step %}
**Show deleted objects**

Enable **Show deleted files**. The meta-directory of the lost database appears grayed out.
{% endstep %}

{% step %}
**Restore**

1. Select the checkbox of the database meta-directory
2. Select **Restore → Execute**
3. Confirm the settings and start the restore
   {% endstep %}
   {% endstepper %}

If the database was in archive logging mode at the time of the backup, Tina can apply the logs automatically.

#### Restore a previous version of a database

Use this when you want the database **to be as it was at an earlier backup**, without applying more recent logs.

**Disable automatic rollforward**

Set:

* `TINA_DB2_ROLLFORWARD=no`

Reset it after the restore if you need automatic rollforward again later.

**Restore using the Synchronizer**

{% stepper %}
{% step %}
**Synchronize to the restore point**

1. select the database **Synchronizer** meta-file
2. open **Tree → Selection → Versions**
3. select the desired version
4. click **Synchronize**
   {% endstep %}

{% step %}
**Restore**

1. select the checkbox of the database meta-directory
2. select **Restore → Execute**
   {% endstep %}

{% step %}
**(Optional) Apply rollforward manually**

If you disabled automatic rollforward, the database ends up in rollforward-pending state.

You can apply rollforward up to a specific point, then complete:

```
db2 rollforward db <db> to YYYY-MM-DD-HH.MM.SS and complete
```

Or apply rollforward to the end of the logs:

```
db2 rollforward db <db> to end of logs and complete
```

{% endstep %}
{% endstepper %}

### Graphical Mode: specific scenarios

#### Log restore directory overflow

If the default log restore directory is too small, set:

* `TINA_DB2_OVERFLOW_LP=<directory>`

#### Restore to another database (same instance)

Set:

* `TINA_DB2_TARGET_DB=<new_name>` (8 characters max)

{% hint style="warning" %}
When `TINA_DB2_TARGET_DB` is set, restore **one database per session**.
{% endhint %}

#### Restore to another directory

Set:

* `TINA_DB2_TARGET_PATH=<path>`

On Windows, use a drive syntax, such as `C:`.

#### Automatic Storage (DB2 9.1+): redirect data, config, and logs

Use these variables:

* `TINA_DB2_REDIRECT_PATH=<path1,path2,...>`\
  Restore paths for data files.
* `TINA_DB2_TARGET_PATH=<path>`\
  Path for the configuration file.\
  Also used for the log path if `TINA_DB2_NEWLOGPATH` is not set.
* `TINA_DB2_NEWLOGPATH=<path>`\
  Separate, optional log restore path.

Redirection rules:

* If you set `TINA_DB2_TARGET_PATH` and `TINA_DB2_NEWLOGPATH`, logs go to `TINA_DB2_NEWLOGPATH`.
* If you set only `TINA_DB2_TARGET_PATH`, the configuration and logs go to `TINA_DB2_TARGET_PATH`.
* If you set neither, the configuration and logs go to the instance's default database path.

#### Non-automatic storage (DB2 9+): redefine tablespace containers

Set:

* `TINA_DB2_CONTAINER_CFG=<script_path>`

The script must contain DB2 `set tablespace containers ...` commands.

This is useful when DB2 returns:

`SQL0294N The container is already in use`

{% hint style="warning" %}
Do not set `TINA_DB2_CONTAINER_CFG` at the same time as `TINA_DB2_REDIRECT_PATH`.\
Tina cancels the restore.
{% endhint %}

#### Mirror log path issues after a cross-restore

DB2 can fail recovery if it tries to reuse the **original** mirror log path.

Fix:

1. set a new `MIRRORLOGPATH` on the restored database
2. run:

```
db2 rollforward db <db> to end of logs and complete
```

{% hint style="warning" %}
When cross-restoring a database that uses mirror logs, do not set `TINA_DB2_OVERFLOW_LP`.
{% endhint %}

#### Restore a database alias

You can restore an alias meta-link.

Before restoring, drop it with:

```
db2 uncatalog db <alias>
```

#### Dump the backup image to disk

To restore the DB2 backup file to disk instead of restoring a database, set:

* `TINA_DB2_DUMP_TO_DISK=<existing_directory>`

Make sure the directory has enough free space.

#### Cross-restore (to another instance)

Prerequisites:

* same OS and OS version on the source and target
* same DB2 version on the source and target
* Tina installed on both hosts
* the user has rights to open the source backup folder

Graphical workflow:

1. create a second DB2 application on the target host
2. open Restore & Archive Manager on the target application
3. use **Backup → Application → Folder** to select the source application's folder
4. select the database and run **Restore → Execute**

Command-line cross-restore:

```
tina_restore -folder <source_application_folder> -folder_dest <target_application_folder> -catalog <catalog> -path_folder /<instance>/<db>
```

### Command Mode restore

Command Mode uses standard DB2 commands with the Tina vendor library.

#### Restore the most recent backup

```
db2 restore database <db> load "<absolute_path_to_libtina_db2vp>"
```

Example (Windows-style path):

```
db2 restore database SAMPLE load "C:\Program Files\Atempo\Bin\libtina_db2vp_10.dll"
```

#### Restore a specific backup version

1. Find the timestamp of the DB2 backup.\
   You can read it in Tina's versions or via DB2 history:

```
db2 list history backup all for database <db>
```

2. Restore:

```
db2 restore database <db> taken at <YYYYMMDDHHMMSS> load "<lib_path>"
```

DB2 accepts a shortened date such as `YYYYMMDD`.\
It then restores the most recent backup of that day.

#### Point-in-time recovery (restore + rollforward)

You need the archived logs for this workflow.

1. Restore a backup image (often the last full backup before the target time).
2. Apply rollforward up to the target timestamp, then complete.

From DB2 8.2+, use `without rolling forward` if you want a manual rollforward:

```
db2 restore database <db> load "<lib_path>" taken at <YYYYMMDDHHMMSS> without rolling forward
```

Then apply rollforward:

```
db2 rollforward db <db> to YYYY-MM-DD-HH.MM.SS and complete
```

#### Restore with multiple sessions

If the backup was multi-session, open the same number of sessions:

```
db2 restore database <db> load "<lib_path>" open <N> sessions
```

#### Apply rollforward (log recovery)

After the restore, DB2 often ends up in rollforward-pending state.

Apply rollforward to the end of the logs:

```
db2 rollforward database <db> to end of logs and complete
```

#### DB2 prompts and messages

DB2 may ask for confirmation when overwriting an existing database:

`SQL2539W ... Do you want to continue? (y/n)`

#### Troubleshooting

If the restore or rollforward fails, check:

* the DB2 messages in the CLP output
* the DB2 diagnostic log:
  * Windows: `%INSTANCE_HOME%\db2diag.log`
  * Unix: `$INSTANCE_HOME/sqllib/db2dump/db2diag.log`
* Tina events in the Web Administration Console

Some "missing log" errors at the end of rollforward can be benign.\
Trust DB2's final status message.

### Advanced (Command Mode)

#### HADR (High Availability Disaster Recovery)

HADR replicates log records from a **primary** DB2 server to a **standby** server.

HADR does not move large payloads.\
Use Tina when you need to transfer large backups or load data.

Key requirements:

* Tina installed on both DB2 servers
* the same `TINA_HOME` path on both servers
* the same Tina archive folder on both servers

**Initialize HADR using Tina**

Back up on the primary, then restore on the standby:

```
db2 backup database <db> load "<lib_path>"
db2 restore database <db> load "<lib_path>" taken at <timestamp> replace history file
```

**LOAD FROM with COPY YES**

To make load files available to the standby without shared storage:

```
db2 load from <file> of del insert into <table> copy yes load "<lib_path>"
```

#### Spectrum Protect Snapshot (FlashCopy)

DB2's Advanced Copy Services can use a snapshot script.\
Tina can back up and restore the snapshot content.

High-level restore command:

```
db2 restore db <db> use snapshot script <script_path> taken at <timestamp>
```

If you encounter `SQL2081N ... Reason code = "2"`, first remove the remaining DB files.\
This usually means there are stale files in the target database's directories.

### Meta-tree

This topic covers the DB2 meta-tree. It describes its structure and the objects it contains:

* [<mark style="color:blue;">Meta-tree</mark>](#meta-tree)
* [<mark style="color:blue;">Meta-tree objects</mark>](#meta-tree-objects)

#### Meta-tree

The Restore and Archive interface is now connected to the DB2 instance. By double-clicking the directories, you can browse the meta-tree used to represent the DB2 instance.\
Tina for DB2 Graphical Mode uses the DB2 programming interface to access the DB2 administration table and provide a representation of the instance. The order of the meta-tree defines the order in which the different objects are backed up. The backup runs top-down through the meta-tree of the Restore and Archive interface.

#### Meta-tree objects

Tina's application meta-trees are made up of objects whose model is comparable to a POSIX file system.

**Object naming**

Each meta-tree object has a meta-path. Like in a POSIX system, an object's meta-path is made up of the names of each of its ancestor meta-directories and ends with the name of the object itself, with each element separated by a slash character '/'.\
**Example**. the meta-file representing the SAMPLE database may have the meta-path <kbd>/db2inst1/SAMPLE/database.</kbd>\
This meta-path is used to reference objects in Tina commands such as tina\_ restore.

**Object status**

Meta-objects have a colored status LED, as follows:

<table><thead><tr><th width="242.33331298828125">Color</th><th>Status</th></tr></thead><tbody><tr><td><strong>Gray</strong></td><td>Unknown</td></tr><tr><td><mark style="color:$success;"><strong>Green</strong></mark></td><td>Accessible</td></tr><tr><td><mark style="color:$warning;"><strong>Orange</strong></mark></td><td>Transitioning</td></tr><tr><td><mark style="color:red;"><strong>Red</strong></mark></td><td>Unavailable</td></tr></tbody></table>

**Object description**

<table><thead><tr><th width="152.33331298828125">Meta-tree objects</th><th>Description</th></tr></thead><tbody><tr><td><strong>Meta-files</strong></td><td>Objects containing data to be backed up are represented as meta-files. Meta-file attributes are recorded in the Tina catalog and on the media. Meta-file data is only backed up on the media.</td></tr><tr><td><strong>Meta-links</strong></td><td>A meta-link is an object that only has attributes and contains no data to back up. These attributes are recorded both in the Tina catalog and on the media.</td></tr><tr><td><strong>Meta-directories</strong></td><td>Meta-directories are structural groupings of objects, which can themselves be grouped into a meta-directory. The top-level meta-directory is called the meta-root. Its symbol is the slash '/'.</td></tr></tbody></table>

### DB2 objects

The meta-objects of a DB2 instance are described below in their backup order.\
The following figure is an example of a DB2 meta-tree.

<table><thead><tr><th width="210.3333740234375">DB2 objects</th><th>Description</th></tr></thead><tbody><tr><td><strong>Root meta-directory /</strong></td><td>This meta-directory is the entry point of the meta-tree. It is displayed as soon as the Restore and Archive interface is initialized, before connecting to the DB2 instance.</td></tr><tr><td><strong>Information meta-directory</strong></td><td>This meta-directory contains the environment variables of Tina for DB2 Graphical Mode, as well as information about the environment.</td></tr><tr><td><strong>Instance meta-directory</strong></td><td>This meta-directory is named after the DB2 instance. It appears as soon as Tina has connected to the DB2 instance. It contains the meta-directories representing the databases.</td></tr><tr><td><strong>Database meta-directories</strong></td><td>These meta-directories are named after the databases they are associated with. They contain the meta-file associated with the database, the log files meta-directory, and the Synchronizer meta-file. There is no meta-directory for log files nor a Synchronizer meta-file for databases that do not support online backups.</td></tr><tr><td><strong>Alias meta-link</strong></td><td>These meta-directories are named after the aliases they are associated with. The target is the name of the database accessible via this alias. The alias comment is displayed in parentheses.</td></tr><tr><td><strong>database meta-file</strong></td><td><p>The <em>database</em> meta-file has a fixed name and represents the database of the parent meta-directory.</p><ul><li><strong>Red</strong> LED: suspect, offline, stopped, or not reloaded database → restore required.</li><li><strong>Orange</strong> LED: database in transition (backup, restore, rollforward). Visible attributes: access date, backup mode, first active log file, meta-object name. Size is estimated by adding up the data and log files.</li></ul></td></tr><tr><td><strong>Logs meta-directory</strong></td><td><p>The <em>Logs</em> meta-directories have a fixed name. They contain the log meta-files and a meta-link indicating the physical location of the log files (<strong>LOGPATH</strong> parameter).</p><ul><li><strong>Green</strong> LED: active log</li><li><strong>Orange</strong> LED: archived log Offline archived logs are visible if the show deleted files option is enabled after a backup. These directories only appear if the database supports online backups.</li></ul></td></tr><tr><td><strong>mirrored_log meta-link</strong></td><td>Indicates the path of the directory where copies of the mirror log files are stored.</td></tr><tr><td><strong>logarchmeth1 and logarchmeth2 meta-links</strong></td><td>Indicate the path of the archived log files used by DB2. This path is built automatically from the path defined in the <strong>DISK</strong> method (with the instance name, database, node, and string appended). Available only if the DISK method is used (from DB2 version 8.2).</td></tr><tr><td><strong>Synchronizer meta-file</strong></td><td>This meta-file contains no direct data, but Tina creates a version on every backup. Each version inherits attributes (mode, backup type, first active log) and represents a possible restore point for the associated database.</td></tr></tbody></table>

### Additional information

This topic provides information on the List of environment variables as well as on Upgrading DB2: v9 to v10.

#### List of environment variables

This topic presents the environment variables of Tina for DB2 Graphical Mode.\
Required variables must be added to Tina's DB2 application. Declare\
optional variables as needed.

| Environment variable            | Possible values \[default]                                                                                                                                             | Function                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Status   |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `DB2INSTANCE`                   | String\[Name of the logged-in user]                                                                                                                                    | Name of the current DB2 instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Optional |
| `TINA_APP_LIB_PATH`             | PathAutomatically set to `(libtina_db2_?.so)` or `(libtina_db2_?.sl)` on Unix, `(libtina_db2_?.a)` on AIX, and `(libtina_db2_?.dll)` on Windows                        | Path to the software library of Tina for DB2 Graphical Mode.The `?` must be replaced by the DB2 version number (8, 9, or 10), with the parentheses removed.For DB2 version 8.1 FP15 on a Linux kernel 2.6, replace `?` with `8_fp15`.For DB2 version 8 on a 64-bit Solaris platform with a 32-bit instance, replace `?` with `8_32`.                                                                                                                                                         | Required |
| `TINA_DB2_BUFFER_NUMBER`        | Integer between 1 and 64\[2]                                                                                                                                           | Number of buffers used by DB2 during backups and restores.                                                                                                                                                                                                                                                                                                                                                                                                                                   | Optional |
| `TINA_DB2_BUFFER_SIZE`          | Integer between 16 (64 KB) and 1,048,576 (4 TB)\[16]                                                                                                                   | Size of the buffers (number of 4 KB pages) used by DB2 during backups and restores.It is strongly recommended to use the same buffer size for backup and restore.                                                                                                                                                                                                                                                                                                                            | Optional |
| `TINA_DB2_COMPRESS`             | yes\[no]                                                                                                                                                               | Enables compression of database backups via DB2. This option applies from DB2 V8 FP4 onward.                                                                                                                                                                                                                                                                                                                                                                                                 | Optional |
| `TINA_DB2_CONTAINER_CFG`        | Path.Must be an existing file that contains `set tablespace` commands.                                                                                                 | From DB2 V9.Redefines the tablespace containers when restoring a database that is NOT in Automatic Storage.The variable must contain the full path of a configuration script containing commands of the form:`set tablespace containers for 0 using (path '/home/db2i95_1/conteneur0')`The `TINA_DB2_CONTAINER_CFG` variable cannot be used together with the `TINA_DB2_REDIRECT_PATH` variable. A warning message is displayed and the restore is canceled if both variables are specified. | Optional |
| `TINA_DB2_DUMP_TO_DISK`         | Path.Must be an existing directory that will contain the backup file with the database backup. There must be enough space in the directory to restore the backup file. | Restores the backup to a backup file (rather than to a database).                                                                                                                                                                                                                                                                                                                                                                                                                            | Optional |
| `TINA_DB2_INST_PTR_SIZE`        | 32 \[64]                                                                                                                                                               | Parameter indicating the word length when creating an instance.Set the variable to 32 to back up a 32-bit instance on a 64-bit platform.Solaris only.                                                                                                                                                                                                                                                                                                                                        | Optional |
| `TINA_DB2_NEWLOGPATH`           | Path                                                                                                                                                                   | From DB2 V9.Path to the directory to which DB2 log files are redirected during restore (see specific scenarios).                                                                                                                                                                                                                                                                                                                                                                             | Optional |
| `TINA_DB2_OPEN_TIMEOUT_BACKUP`  | Integer in seconds \[120]                                                                                                                                              | Specifies the connection timeout to the DB2 server during a backup. Cannot be lower than the default value.                                                                                                                                                                                                                                                                                                                                                                                  | Optional |
| `TINA_DB2_OPEN_TIMEOUT_RESTORE` | Integer in seconds \[600]                                                                                                                                              | Specifies the connection timeout to the DB2 server during a restore. Cannot be lower than the default value.                                                                                                                                                                                                                                                                                                                                                                                 | Optional |
| `TINA_DB2_OVERFLOW_LP`          | Directory path                                                                                                                                                         | Path of a directory to which the log files are restored when the space allocated by DB2 is not sufficient.During recovery (rollforward), this path is provided to DB2.                                                                                                                                                                                                                                                                                                                       | Optional |
| `TINA_DB2_REDIRECT_PATH`        | Comma-separated list of paths                                                                                                                                          | **Before DB2 V9.1:**&#x43;estore path for DMS database containers if a redirected restore is required (e.g. `SQL0294N The container is already in use` error).**From DB2 V9.1:**&#x43;ath to the directory to which Automatic Storage databases are redirected. Can contain multiple paths separated by commas.Example:`/home/db2user/data1,/home/db2user/data2`Cannot be used together with `TINA_DB2_CONTAINER_CFG`.                                                                       | Optional |
| `TINA_DB2_ROLLFORWARD`          | \[yes] no                                                                                                                                                              | Lets you automatically recover (rollforward) log files at the end of a restore session for databases whose status is *rollforward pending*.                                                                                                                                                                                                                                                                                                                                                  | Optional |
| `TINA_DB2_TARGET_DB`            | String (≤ 8 characters)                                                                                                                                                | Substitute name you want to give the restored database.                                                                                                                                                                                                                                                                                                                                                                                                                                      | Optional |
| `TINA_DB2_TARGET_PATH`          | Path                                                                                                                                                                   | **Before DB2 V9.1:**&#x43;arget restore path if you are restoring to a directory different from the original one. Only useful if `TINA_DB2_TARGET_DB` is set.**From DB2 V9.1:**&#x43;arget restore path for a database's configuration files and log files.Useful in most specific restore scenarios.On Windows, the path consists of the drive name (e.g. `C:`).                                                                                                                            | Optional |

#### Upgrading DB2: v9 to v10

DB2 v10 uses a different directory structure for archiving log files, i.e. <kbd>LOGARCHMETH1 = DISK</kbd>. If you use this setting, follow these steps when upgrading a DB2 v9 database to DB2 v10:

**Upgrade DB2 v9 to v10**

1. Take the database offline.
2. Back up the database.
3. Set the logarchmeth1 parameter to logretain or none.
4. Upgrade the database to DB2 v10.
5. Set the logarchmeth1 parameter to DISK.
6. Back up the database to activate the new setting.
7. Bring the database back online.

> **Note**: Tina for DB2 does not support IBM's PureScale product.


---

# 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/restore/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.
