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

# SQL Server

## Backing Up Microsoft SQL Server with Tina <a href="#sauvegarder-microsoft-sql-server-avec-tina" id="sauvegarder-microsoft-sql-server-avec-tina"></a>

This page explains how to protect a Microsoft SQL Server instance using **Tina for SQL Server**.

### About <a href="#a-propos" id="a-propos"></a>

Tina for SQL Server is an agent module that performs **hot backups**. SQL Server stays online during backups. It supports:

* **Full backups** of databases.
* **Incremental backups** using:
  * **transaction log backups**
  * **differential backups**
* **VSS** (Volume Shadow Copy) for **full backups only**.

VSS is supported **only** for full backups.

<details>

<summary><strong>How Tina backs up SQL Server (VDI and VSS)</strong></summary>

**VDI mode (default)**

Tina connects to SQL Server via T-SQL.\
SQL Server streams backup data via VDI (Virtual Device Interface).

During a full backup:

* `tina_backup` creates a stored procedure `tina_sqlcmd`.
* `tina_sqlcmd` launches the database backup command via VDI.
* `tina_backup` reads the VDI stream and writes it to the backup media.

If SQL Server reports an error, Tina marks the version as "fuzzy" (inconsistent/unreliable).

**VSS mode (full backups only)**

When `TINA_SQL_VSS=yes`, Tina requests a VSS snapshot and backs up the replica.

VSS coordination:

* Requestor: Tina
* Writer: SQL Server SQL Writer
* Provider: storage snapshot provider (software or hardware)

</details>

**What Tina exposes in Restore & Archive Manager**

In Restore & Archive Manager, the SQL Server application exposes a meta-tree. You will typically see:

* **Information**: environment variables and runtime information.
* **config**: SQL Server configuration objects (used to rebuild the SQL Server configuration).
* **databases**: one meta-directory per database (system and user databases).
* **Synchronizer**: a meta-file versioned at each backup. It represents the backup entry points.

<details>

<summary><strong>SQL Server concepts (instances, files, recovery model)</strong></summary>

**Instances**

* A **default instance** is identified by the server's network name.
* A **named instance** is identified by `server\instance`.

**Storage structures**

* Databases are divided into:
  * **system databases** (`master`, `model`, `msdb`, `tempdb`)
  * **user databases**
* Data is stored in:
  * **primary data file** (`.mdf`)
  * **secondary data files** (`.ndf`, optional)
  * **transaction log files** (`.ldf`)
* Data files can be grouped into **filegroups**.

**Backup mechanisms (SQL Server side)**

* **Full**: copy of the database (except empty pages).
* **Differential**: pages changed since the last full backup.
* **Transaction log**: log backup (with or without truncation).

**Recovery model**

* **Simple**: logs are truncated at checkpoints. No transaction log backups.
* **Bulk-logged**: log backups possible. Point-in-time recovery not supported.
* **Full**: log backups possible. Best recovery capabilities.

**FILESTREAM (SQL Server 2008+)**

FILESTREAM stores BLOBs in NTFS, while maintaining transactional consistency via the logs.

</details>

### Create the agent (SQL Server application) <a href="#creer-lagent-application-sql-server" id="creer-lagent-application-sql-server"></a>

Create **one SQL Server application per SQL Server instance** that you want to protect.

**Prerequisites**

* Install a Tina agent on the SQL Server 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)
* Validate the OS and SQL Server versions in the [Compatibility Guide.](https://documentation.atempo.com/tina-4.9.5/tina-4.9.5-en/version-information/compatibility-guide.md)
* Make sure the SQL Server service is running:
  * `SQL Server (<instance_name>)`
* The access user configured in the application must be a member of the **sysadmin** fixed server role.
* If you want transaction log backups:
  * use the **Full** or **Bulk-Logged** recovery model for the databases.

If a database uses the **Simple** recovery model, Tina runs **differential backups** only.

**VSS prerequisites (only if you enable VSS full backups)**

* Windows VSS must be available.
* SQL Server **SQL Writer** must be present and running (SQL Server 2005+).

### Create and activate the application

#### Start the application creation wizard <a href="#id-1-demarrez-lassistant-de-creation-dapplication" id="id-1-demarrez-lassistant-de-creation-dapplication"></a>

In the Web Administration Console:

1. go to **Platforms → Applications**
2. click **New application**

#### Define the application settings <a href="#id-2-definir-les-parametres-de-lapplication" id="id-2-definir-les-parametres-de-lapplication"></a>

Define:

* **Host**: the machine running SQL Server
* **Application type**: SQL Server
* **Application name**: unique name (it becomes the name of the backup folder)
* **Access user**: SQL Server login (or Windows account) with `sysadmin` rights
* **Credentials**: password for this login

If the instance is named, plan to set `TINA_SQL_INSTANCE`.3

#### Define the required environment variables <a href="#id-3-definir-les-variables-denvironnement-requises" id="id-3-definir-les-variables-denvironnement-requises"></a>

Define at minimum:

* `TINA_SQL_LOG_DEST` (required)

This is the on-disk staging directory for transaction log backup files during incremental backups.4

#### Finish and activate the application <a href="#id-4-terminer-et-activer-lapplication" id="id-4-terminer-et-activer-lapplication"></a>

1. review the summary
2. click **Finish**
3. in the Applications list, select it and click **Activate application**

#### Validate access (recommended)

Open **Restore & Archive Manager** on the SQL Server application.

If the meta-tree loads without errors, Tina can connect and enumerate the databases.

### Back up SQL Server

You do not need to stop SQL Server to run backups.

#### Backup scope: system objects vs. user objects

SQL Server objects fall into two categories:

* **System meta-objects**: SQL Server configuration and key system databases.
  * They rarely change.
  * Any change is critical.
  * The `master` database supports **full backups** only.
* **User meta-objects**: user databases.
  * They can be large.
  * They change often.
  * Incremental optimization matters.

A typical schedule looks like:

* Full: weekly
* Differential: daily
* Transaction log: every 2 hours

#### Configure automatic backups

Use the **Backup Wizard** to link:

* a selection (what to back up)
* a strategy (when and where)

#### Backup selections (what to back up)

By default, a selection exists at the root of the application (`/`).

Keep it unless you have a good reason to split selections.

The default root selection is:

* associated with all strategies
* not filtered
* not time-based
* not compressed or encoded

{% hint style="warning" %}
SQL Server database names must not contain these characters: `\/:*?"<>`
{% endhint %}

**AlwaysOn Availability Groups (SQL Server 2012+)**

If your instance runs in AlwaysOn availability mode, set the instance's backup preference to:

* **Primary replica only**

Backing up the secondary replica is not supported by Tina for SQL Server.

{% hint style="warning" %}
Avoid associating selections with a specific replica node.

After a failover, the former primary can become secondary and disappear from the meta-tree.
{% endhint %}

#### Backup strategies (avoid overlaps)

Use **one strategy per database**.

Overlapping strategies can break the transaction log chain.

#### Parallel backups (optional)

Parallelization is configured at the **selection** level.

1. create selections on the databases you want to parallelize
2. enable **Parallelize backups if possible** in the selection options
3. set the strategy's **Parallelism index** to a value `> 1`

{% hint style="warning" %}
Only parallelize **database selections. Do not parallelize objects unrelated to databases.** Do not parallelize objects unrelated to databases.
{% endhint %}

#### Full backups (VDI vs. VSS)

By default, Tina uses **VDI** (Virtual Device Interface).

If `TINA_SQL_VSS=yes`, Tina uses a VSS snapshot for the full backup.

Tina can automatically switch to a full backup if, for example:

* the last full backup is unusable
* `journal de sauvegarde` fails
* a transaction log truncation is detected
* the required on-disk transaction log backups are missing
* a non-Tina backup has occurred since the last backup (unless it used SQL Server `copy_only`)

#### Incremental backups (logs + differential)

Tina alternates between two incremental types:

* **transaction log backups**
* **differential backups**

By default, incremental backups run as **transaction log backups**.

To trigger differential backups, set `TINA_SQL_DIFF_LEVEL`:

* not set: transaction log backups only
* `0`: differential backups only
* `N > 0`: run `N` transaction log backups, then a differential

Notes:

* In the **Simple** recovery model, Tina runs **differential** only.
* For the `master` database, Tina performs **full backups** (even when you launch incremental ones).

<details>

<summary>Incremental levels and file naming (reference)</summary>

Incremental objects use a naming pattern such as:

`tina.<full>.<diff>.<log>.<ext>`

Example (transaction log):

`tina.0029.01.0000000051.l`

* `<full>`: full backup level
* `<diff>`: differential level
* `<log>`: transaction log level (monotonic, never reset)
* `<ext>`:
  * `.l` for transaction log backups
  * `.d` for differential backups

Tina uses SQL Server history (for example `msdb..backupset`) to manage differential triggering and track the required log chains.

</details>

#### Staging and transaction log truncation

During a transaction log backup:

1. Tina runs `journal de sauvegarde` into a file on disk.
2. The destination directory is:
   * `TINA_SQL_LOG_DEST\<database>\...`
3. Tina then copies the file to the backup media.

`TINA_SQL_LOG_TRUNC` controls whether logs are truncated during the backup:

* `yes` (default): normal operation, frees up space
* `no`: backup without truncation

{% hint style="warning" %}
If `TINA_SQL_LOG_TRUNC=no`, you cannot run differential backups.
{% endhint %}

Tina can also purge old log backup files present on disk.

Use `TINA_SQL_LOG_RET` to keep the logs of the **N most recent full backups**.

#### Run a manual backup

1. go to **Platforms → Applications**
2. select the SQL Server application
3. click **Launch backup**
4. choose **Full** or **Incremental**

The backup starts if no other session is already running for the strategy.

### Environment variables

You can set variables:

* when creating the SQL Server application
* from the application details page
* from Restore & Archive Manager (Information node)

#### Required

* `TINA_APP_LIB_PATH`\
  Path to the Tina libraries for SQL Server.\
  Default: `%TINA_HOME%\Bin\libtina_sql.dll`
* `TINA_SQL_LOG_DEST`\
  Directory used to stage transaction log backup files during backups.\
  Example: `TINA_SQL_LOG_DEST=D:\tina\sql`

#### Backup behavior and performance

* `TINA_SQL_BCK_TIMEOUT` (default: `86400`)\
  Backup open timeout (seconds) for named pipes / virtual devices.
* `TINA_SQL_ENV_DEVICE_OPEN_TIMEOUT` (default: `300`)\
  Timeout (seconds) to set up the VDI device set.
* `TINA_SQL_LOGIN_TIME` (default: `5`)\
  Timeout for connecting to SQL Server (seconds).
* `TINA_SQL_CHECKSUM` (default: `no`)\
  Passes `CHECKSUM` to SQL Server's full/differential backup commands.
* `TINA_SQL_ON_ERROR` (default: `stop`)\
  Passes `STOP_ON_ERROR` or `CONTINUE_AFTER_ERROR` to the backup/restore commands.
* `TINA_SQL_NATIVE_DRIVER` (default: `off`)\
  Use the SQL Native Driver instead of the SQL ODBC driver.

#### Incremental strategy (logs vs. differential)

* `TINA_SQL_DIFF_LEVEL` (default: `-1`)\
  Differential trigger threshold.\
  Not set means "no differential". `0` means "always differential".
* `TINA_SQL_LOG_TRUNC` (default: `yes`)\
  Truncate logs when backing them up (`yes`) or keep them (`no`).
* `TINA_SQL_LOG_RET` (default: `10`)\
  Number of full backups used to determine on-disk log retention.

#### Instance and connection targeting

* `TINA_SQL_INSTANCE` (default: machine name)\
  SQL Server instance name.
* `TINA_SQL_SERVER_NAME`\
  SQL Server network name if it differs from the host where SQL Server runs.

#### VSS mode (full backups only)

* `TINA_SQL_VSS` (default: `off`)\
  `yes`: use VSS for full backups.\
  `off`: use VDI.

<details>

<summary><strong>Restore-related variables (reference only)</strong></summary>

These variables are mainly used during restore workflows.

They are listed here for completeness, without restore procedures.

* `TINA_SQL_DB_DEST`\
  Name of the destination database.
* `TINA_SQL_MOVE_DATA_TO`\
  Target path for restored data files. Also supports `CLAUSE=...` for move request files.
* `TINA_SQL_RST_TIMEOUT` (default: `172400`)\
  Restore open timeout (seconds) for named pipes / virtual devices.
* `TINA_SQL_STAND_BY`\
  Path to the undo file for standby restores.
* `TINA_SQL_VERIFY_ONLY` (default: `no`)\
  Verify the backup set's readability without restoring data.

</details>


---

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