# How to Restore a Corrupted Tracker Database

CopyStorm/Restore uses a small footprint relational database ([based on H2](https://www.h2database.com/html/main.html)) to keep track of all restore activity. Like any database, it is possible (but rare) for this database to become corrupted. This article explains how to recover a corrupted H2 database.

## Step 1: Create a New Directory and….

1. Copy the corrupted H2 database into the new directory.
2. Copy the file `[CopyStormRestore Install Directory]/lib/h2*.jar` into the new directory.
3. Open a command prompt and run `java -cp h2*.jar org.h2.tools.Recover`
4. The previous step will create a .txt file with the same name as your database. It may take a while to run and does not produce output.

## Step 2: Restore the recovery file created into Step 1 into a new database.

`java -cp h2*.jar org.h2.tools.RunScript -url "jdbc:h2:file:~/tmp/RecoveredTracker" -user root2 -password capstorm -script EMR-UAT-tracker.mv.txt -showResults`

* The database in the `-url` parameter should not exist.
* The `-user` and `-password` parameter should NOT match a user in your corrupted database. `root`/`capstorm` are the defaults for a CopyStorm/Restore tracker database.
* The `-script` argument is the recovery file created in the first step.

## Step 3: Look at the recovered tracker database using the H2 Console application.

## Step 4: Look at the recovered tracker database using CopyStorm/Restore.

Of course, there is no guarantee that the recovery will work. Each case is likely to be unique. However, if the following tables are intact and have data there is a decent chance of recovery.

* `RestoreConfig` — this table must have values. It is used by CopyStorm/Restore to determine the version of the tracker database.
* `RestoreTable` — this table lists all Salesforce tables in the tracker and references to a unique tracking table for each Salesforce table. Do a `SELECT *` on this table.
* `RestoreTableRecordReference` — this is a utility table used to track reference ids that need to be patched in a second pass. It may or may not be empty but must exist.
* `SkippedRecordReason` — this table can be empty but must exist.
* `RestoreException` — this table can be empty but must exist.
* `RestoreHistory` — this table can be empty but must exist.

See this article for details about what is in a tracker database.

{% file src="/files/ysgUxyzd5nYje7K8dSWM" %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/copystorm-restore/frequently-asked-questions/how-to-restore-a-corrupted-tracker-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
