> For the complete documentation index, see [llms.txt](https://learn.capstorm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.capstorm.com/copystorm-restore/frequently-asked-questions/how-to-restore-a-corrupted-tracker-database.md).

# 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" %}
