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

# SQL Server

## Restore Microsoft SQL Server with Tina

Tina for SQL Server supports several restore scenarios.

Restores can run from:

* Standard **VDI** backups
* Full **VSS** backups

### Prerequisites

#### Take the database offline

Before restoring a database, make sure it is **offline** in SQL Server.

This avoids active connections and file locks.

#### Stop SQL Server backups during the restore

Restores use the same storage resources as backups.

Stop or pause SQL Server backup jobs before restoring.

#### User rights for the restore

The Windows user running the restore must match the Windows session on the SQL Server host.

This is a common source of "access denied" errors and file ownership issues.

#### Mandatory disk staging directory

You must set `TINA_SQL_LOG_DEST`.

Tina uses it to stage incremental objects on disk during the restore and recovery.

### SQL Server restore test (verify only)

Use verify-only mode to validate a backup set.

No data is restored.

It checks:

* the completeness of the backup chain
* that SQL Server could read the restored volumes

{% stepper %}
{% step %}

#### Enable verify-only mode

1. Open **Restore & Archive Manager** in the SQL Server application.
2. Expand **Information**.
3. Right-click `TINA_SQL_VERIFY_ONLY` and select **Properties**.
4. Set the value to `oui`.
   {% endstep %}

{% step %}

#### Synchronize on a restore point

1. Select **Backup → Strategy** and choose the strategy containing your backups.
2. Select **Synchronizer**.
3. Select **Tree → Selected objects → Versions**.
4. Choose a version (usually the most recent).
5. Click **Synchronize**.
   {% endstep %}

{% step %}

#### Run the restore

1. Select the objects you would normally restore (see the scenarios below).
2. Select **Restore → Run**.
3. Configure the restore settings and click **OK**.

If the backup set is valid, SQL Server returns:

> The backup set is valid
> {% endstep %}
> {% endstepper %}

{% hint style="warning" %}
Reset `TINA_SQL_VERIFY_ONLY` to `non` before any real restore.
{% endhint %}

### Scenario 1: Restore the `master` database

Restore `master` when SQL Server does not start and the error log does not show **Recovery complete**.

This procedure has four phases:

1. rebuild an empty master
2. redefine Tina's access login
3. restore `master`
4. verify the databases and logins

#### Step 1: Rebuild the `master` database

Use Microsoft's rebuild procedure for your version of SQL Server.

{% hint style="info" %}
If you have a cold copy of `master.mdf` captured while SQL Server was stopped, you can use it instead.
{% endhint %}

<details>

<summary><strong>Example command for SQL Server 2008/2012</strong></summary>

From an elevated command prompt, run:

```
setup.exe /ACTION=REBUILDDATABASE /QUIET /INSTANCENAME=<instance> /SQLSYSADMINACCOUNTS=<comptes>
```

Notes:

* `<instance>` is the named instance, or `MSSQLSERVER` for the default instance.
* Add `/SAPWD` if you use mixed-mode authentication.
* Add `/SQLCOLLATION` if you need to preserve a specific collation.

</details>

<details>

<summary><strong>Example command for SQL Server 2005</strong></summary>

Example syntax (adapt to your paths and instance):

```
setup.exe /q INSTANCENAME=<instance> REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=<mot_de_passe_sa> SQLCOLLATION=<collation>
```

</details>

#### Step 2: Redefine Tina's access login

After the rebuild, recreate the SQL Server login used by Tina.

Make sure it is part of the `sysadmin` fixed server role.

#### Step 3: Restore `master` in single-user mode

1. Stop SQL Server:

```
net stop MSSQL$<nom_instance>
```

2. Start SQL Server in single-user mode:

```
sqlservr.exe -s <nom_instance> -m
```

3. In Restore & Archive Manager:
   * Select **Backup → Strategy**
   * Browse the `master` versions of the database meta-file
   * **Synchronize**
   * Run **Restore → Run**

{% hint style="info" %}
`master` only supports full backups.
{% endhint %}

#### Step 4: Verify the databases and logins

Restart the SQL Server service normally.

Check:

* the state of the system databases (`model`, `msdb`)
* logins and server-level objects

{% hint style="info" %}
Rebuilding `master` also resets `model` and `msdb`. Restore them if you customized them.
{% endhint %}

### Scenario 2: Restore a user database

This restores a database meta-directory.

#### Step 1: Select a restore point using the Synchronizer

Incremental backups create new meta-objects.

They do not create new versions on the database meta-file itself.

Use the **Synchronizer** to browse restore points.

{% stepper %}
{% step %}
**Synchronize on the chosen backup**

1. Open **Restore & Archive Manager** in the SQL Server application.
2. Select **Backup → Strategy** and choose the strategy.
3. Select **Synchronizer**.
4. Select **Tree → Selected objects → Versions**.
5. Choose the version to restore (full or incremental).
6. Click **Synchronize**.
   {% endstep %}

{% step %}
**Select the required objects**

Select:

* The database meta-file (last full backup for this restore point)
* The incremental meta-objects in the `incrémentiel` meta-directory (including the meta-link indicating their location)
* The restore option meta-links as needed:
  * `récupération`
  * `restricted_user`
  * `replace`
  * `keep_replication`

{% hint style="warning" %}
If the database was backed up in **VSS** mode, select **only** the `récupération` option.
{% endhint %}
{% endstep %}

{% step %}
**Run the restore and recovery**

1. Select **Restore → Run**.
2. Configure the restore settings and click **OK**.

Tina stages the incremental objects under:

`%TINA_SQL_LOG_DEST%\<database>\`

Then it applies them during recovery.
{% endstep %}
{% endstepper %}

<details>

<summary><strong>Selection tips (differential/log objects, time browsing, chaining rules)</strong></summary>

**Time browsing**

Differential and log meta-objects can exist only "in the past".

To see them:

* enable **Show deleted files**
* set a **Time browsing** period

**Incremental chaining rules**

* After restoring a **full**, you can apply a **differential** from the same full level.
* After restoring a full/differential/log, you can apply the next log level (`+1`).

</details>

<details>

<summary><strong>Meta-link explanation</strong></summary>

* `récupération`\
  Automatically runs the recovery script after the restore.\
  If you do not select it, recover manually in SQL Server.
* `restricted_user`\
  Limits access to the database to its owner during the restore.
* `replace`\
  Deletes and recreates the database during the restore.\
  Use it only for corrupted databases.
* `keep_replication`\
  Preserves replication settings during recovery.

</details>

<details>

<summary><strong>Recovery script location and content (reference)</strong></summary>

If `récupération` is selected, Tina runs:

`%TINA_SQL_LOG_DEST%\<database>_recover.sql`

The script typically:

1. restores the last full or differential with `NORECOVERY`
2. applies a sequence of `RESTORE LOG ... WITH NORECOVERY`
3. ends with `RESTORE DATABASE ... WITH RECOVERY` (plus options)

</details>

### Scenario 3: Point-in-time recovery (PITR)

Goal: restore the database to a precise point in time **between** backups.

You restore:

* the last full backup before the target time
* the log backups up to (and including) the log containing the target time

Then you replay the logs up to the target time.

{% hint style="warning" %}
This scenario is **not supported** for backups performed in **VSS** mode.
{% endhint %}

#### Procedure (high level)

1. Synchronize on the **transaction log backup** immediately after your target time.
2. Restore the database meta-file + the incremental objects.
3. Do **not** select the `récupération` meta-link.
4. Edit the generated recovery script and add one of:

* `STOPAT = 'YYYYMMDD hh:mm:ss'`
* `STOPATMARK = 'nom_marque'`
* `STOPBEFOREMARK = 'nom_marque'`

5. Run the script in SQL Server Management Studio.

<details>

<summary><strong>Where to edit the recovery script</strong></summary>

Edit:

`%TINA_SQL_LOG_DEST%\<database>_recover.sql`

Add `STOPAT` / `STOPATMARK` / `STOPBEFOREMARK` on the log restore step.

</details>

### Scenario 4: Restore up to the data file crash time (tail-log capture)

If the recovery model is **Full** and the transaction log is still accessible, you can capture the most recent logs.

#### Step 1: Back up the latest transaction logs

1. In the Web Administration Console, open the SQL Server application details.
2. Set:
   * `TINA_SQL_LOG_TRUNC=no`
3. Run an **incremental** backup.

This captures the logs up to the crash time.

#### Step 2: Restore the database

Restore using the selection rules from Scenario 2.

Include the log backup created in the previous step.

{% hint style="info" %}
After the restore, set `TINA_SQL_LOG_TRUNC=yes` again.
{% endhint %}

### Scenario 5: Restore to a different directory

Use this to restore to a different path on the same server.

This can also be used for a cross-restore, if the prerequisites are met.

{% hint style="warning" %}
In VSS mode, cross-restoring between two different SQL instances is not supported by Microsoft SQL Writer.
{% endhint %}

#### Prerequisites

* The source and destination must use the same OS and the same version of SQL Server
* Tina must be installed on both platforms (for cross-restore)
* the user must have cross-restore rights (Tina user settings)
* Make sure the database has no active connections

#### Set the environment variables

Set:

* `TINA_SQL_DB_DEST=<nouveau_nom_de_base_de_données>` (optional)
* `TINA_SQL_MOVE_DATA_TO=<chemin_de_destination>` (required if `TINA_SQL_DB_DEST` is set)

If you prefix the value with `CLAUSE=`, Tina generates an editable move-clause file.

#### Restore

Select:

* the database meta-file
* incremental meta-objects
* `fichiers de données` meta-directory (for move/redirection)
* the restore option meta-links you need

Then run **Restore → Run**.

### Scenario 6: Cross-restore to another SQL Server (single directory)

Use this when:

* The directory structure is identical between the source and destination
* Or you want to move all data files into a single directory

#### Key steps

1. Create a **second SQL Server application** on the destination platform.
2. On the destination application, set:
   * `TINA_SQL_MOVE_DATA_TO=<chemin_de_destination>` (if moving)
   * `TINA_SQL_DB_DEST=<nouveau_nom_de_base_de_données>` (optional)
3. In Restore & Archive Manager, use **Backup → Application → Folder** to browse the source backups.
4. Synchronize with **Synchronizer**.
5. Select the database + the incremental objects (+ `fichiers de données` if moving).
6. Run **Restore → Run**.

### Scenario 7: Cross-restore with redirection to multiple directories

This restores data files to different locations (for example, data vs. logs).

This is a two-pass workflow:

1. create an editable move-request file (structure only)
2. run the actual restore using this edited file

{% hint style="warning" %}
In VSS mode, cross-restoring between two different SQL instances is not supported by Microsoft SQL Writer.
{% endhint %}

#### Step 1: Set up move-request file generation

On the destination SQL Server application, set:

* `TINA_SQL_DB_DEST=<nouveau_nom_de_base_de_données>` (optional)
* `TINA_SQL_MOVE_DATA_TO=CLAUSE=<chemin_vers_fichier_de_demande_de_deplacement>`

Example:

`CLAUSE=F:\sql\move.sql`

#### Step 2: Generate and edit the move-request file

1. In Restore & Archive Manager, synchronize on a restore point.
2. Restore **only** the `fichiers de données` meta-directory.

This creates the move-request file at the specified path.

Edit the file.

Update each `move ... to ...` line to point to the correct destination.

#### Step 3: Run the final restore

Select:

* `base de données`
* `fichiers de données`
* `incrémentiel`
* `synchronizer`
* `récupération`
* `replace` (only if you are overwriting and have not set `TINA_SQL_DB_DEST`)

Then run **Restore → Run**.

### Scenario 8: Restore in standby mode

Standby mode restores a database to a half-restored state.

The database is readable, but not fully recovered.

SQL Server stores uncommitted transactions in an undo file.

#### Prerequisites

Set the undo file path on the destination application:

* `TINA_SQL_STAND_BY=<chemin_du_fichier_undo>`

Example:

`F:\sql_restore\undo`

#### Restore

Restore as in Scenario 2:

* Select the database meta-file
* Select the incremental meta-objects
* Select the restore options

Do **not** select `keep_replication`.

It is incompatible with standby.

### Restore environment variables (quick reference)

These are the most commonly used variables during restore flows:

* `TINA_SQL_LOG_DEST` (mandatory)
* `TINA_SQL_VERIFY_ONLY` (restore test)
* `TINA_SQL_LOG_TRUNC` (tail-log capture flow)
* `TINA_SQL_DB_DEST` (rename the destination DB)
* `TINA_SQL_MOVE_DATA_TO` (data file relocation; supports `CLAUSE=...`)
* `TINA_SQL_STAND_BY` (standby undo file)


---

# 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/sql-server.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.
