> ## Documentation Index
> Fetch the complete documentation index at: https://syteca.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Management

> Manage the Syteca database over its lifetime. Configure Archive and Cleanup operations, clean up sessions left behind by deleted Clients, and tune PostgreSQL autovacuuming to keep the database healthy under sustained write load.

Ongoing Syteca database management covers three operational concerns. Reclaiming space through Archive and Cleanup operations. Tidying the database when Clients are removed and their sessions remain behind. Keeping PostgreSQL databases performing well through automatic vacuuming. This page documents the parameters and procedures for each.

<Warning>
  **NOT AVAILABLE IN SAAS.** Database management is on the on-premises Syteca database. In SaaS deployments, the Syteca vendor manages the database including all Archive and Cleanup operations, deleted-Client tidying, and PostgreSQL maintenance.
</Warning>

## Archive and Cleanup parameters

Archive and Cleanup operations move older session data out of the primary Syteca database. The Cleanup operation removes it entirely; the Archive and Cleanup operation moves it to a separate archived database first, then removes it from the primary database. Both operations share a set of parameters configured on the **Configuration** page.

### Where to configure

1. Click the **Configuration** button at the top of the Management Tool interface.
2. On the Configuration page, select the **Database Management** tab.
3. Scroll to the **Archive Parameters** section.

<Frame caption="Archive Parameters section. Configures both Cleanup and Archive & Cleanup operations from a single place.">
  <img src="https://mintcdn.com/syteca/0FlD-vkHsBA1azVX/images/administration/deployment/database-management-archive-parameters.png?fit=max&auto=format&n=0FlD-vkHsBA1azVX&q=85&s=1de690419633263a0e6db3ebebec904e" alt="Archive Parameters section of the Database Management tab" width="1910" height="1029" data-path="images/administration/deployment/database-management-archive-parameters.png" />
</Frame>

### Parameters applied to Archive & Cleanup for both PostgreSQL and MS SQL Server

These parameters are needed when the Archive & Cleanup operation is used. They point Syteca at the archive destination.

| Parameter                                             | Purpose                                                                                                                                                                                                                                                    |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Instance**                                          | The path to the PostgreSQL or MS SQL Server instance that will host the archived database.                                                                                                                                                                 |
| **Archived database name**                            | The name of the destination database. For MS SQL Server, if the database does not exist, it is created automatically when the Archive & Cleanup operation first runs. For PostgreSQL, the database must exist beforehand.                                  |
| **User** and **Password**                             | Credentials of a user with permissions on the PostgreSQL Server or MS SQL Server instance sufficient to create tables, insert data, and (for MS SQL Server) create the archived database.                                                                  |
| **Binary data location**                              | The path to the location where binary session data (screen captures) will be archived. Only shown when binary storage is used. When using Amazon S3-like storage, this field is replaced by **Bucket name**, **Access key ID**, and **Secret access key**. |
| **Use separate credentials to access binary storage** | Select this checkbox and provide a **User** and **Password** when the binary storage location requires separate credentials, for example a Network-Attached Storage location. Not available with Amazon S3-like storage, which uses its own key/secret.    |

### Parameters applied only to Archive & Cleanup on MS SQL Server

| Parameter                                         | Purpose                                                                                                                                                                                           |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Shrink database transaction log after cleanup** | Runs a transaction log shrink at the end of each Archive & Cleanup operation. Recommended for MS SQL Server deployments where the transaction log grows aggressively during the operation itself. |

### Parameters applied to both Cleanup and Archive & Cleanup

| Parameter                                                                            | Purpose                                                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Archive and clean up the database without archiving and deleting the binary data** | When selected and a binary storage location is configured, screen captures are kept in binary storage even after the database side of the session is cleaned up or archived. Useful when binary storage retention policies differ from database retention policies. |
| **Delete offline Clients without sessions**                                          | Offline Clients that have no recorded sessions are removed from the database during the cleanup process. Prevents orphaned Client records from accumulating when Clients are decommissioned before ever recording a session.                                        |

<Note>
  If binary storage uses Amazon S3-like storage, see [Configure Syteca to Store Binary Data in Amazon S3](/docs/administration/database/binary-storage-s3) for the specific bucket, access key ID, and secret access key configuration.
</Note>

## Clean up sessions of deleted Clients

When a Client is deleted from the Management Tool, most of its data leaves with it. In certain edge cases the Client's sessions can remain in the database as orphaned records. Use the Server Tray application on the Application Server computer to clean up these leftovers.

<Steps>
  <Step title="Open Database Parameters from the Server Tray">
    On the Application Server computer, right-click the **Syteca Server** tray icon in the Notification area and select **Database Parameters**.

    The **Database Parameters** application (`DbSetupToolUI`) opens.
  </Step>

  <Step title="Open the Advanced tab">
    In the Database Parameters application, select the **Advanced** tab.
  </Step>

  <Step title="Start the cleanup">
    Click **Clean up lost sessions**. The cleanup runs against the Syteca database and removes orphaned session records from deleted Clients.
  </Step>
</Steps>

<Note>
  The cleanup can take a long time for large databases. Progress is visible in the Management Tool, on the **Tasks List** tab of the **System Health** page. Verify completion there before assuming the operation is done.
</Note>

## PostgreSQL autovacuuming

PostgreSQL requires periodic maintenance called **vacuuming**. Vacuuming reclaims storage used by rows that are no longer visible to any transaction, and updates statistics the query planner relies on. Without vacuuming, PostgreSQL databases slowly bloat and query performance degrades.

The **Autovacuum Daemon** is a set of PostgreSQL processes that vacuum the database automatically based on activity thresholds. It is enabled in the default PostgreSQL configuration and, in most Syteca deployments, requires no intervention.

### When to change autovacuum settings

Adjust autovacuum settings when the Application Server writes are heavy and default autovacuum tuning is not keeping up with the churn. Symptoms include:

1. Growing database size that outpaces retention-based expectations.
2. Slowing query performance as tables accumulate dead rows.
3. Autovacuum log entries indicating the daemon is running frequently and taking a long time to complete.

### How to change autovacuum settings

Autovacuum settings live in the PostgreSQL configuration file `postgresql.conf`. The location of `postgresql.conf` varies by operating system and PostgreSQL install method. Common locations:

| Platform             | Typical location                                             |
| -------------------- | ------------------------------------------------------------ |
| **Windows**          | `C:\Program Files\PostgreSQL\<version>\data\postgresql.conf` |
| **Ubuntu / Debian**  | `/etc/postgresql/<version>/main/postgresql.conf`             |
| **Red Hat / CentOS** | `/var/lib/pgsql/<version>/data/postgresql.conf`              |

<Steps>
  <Step title="Locate postgresql.conf on the database host">
    Find the `postgresql.conf` file on the database server. Use the platform-specific paths above as a starting point.
  </Step>

  <Step title="Edit the autovacuum settings">
    Open `postgresql.conf` in a text editor with administrator or root permissions. Search for the settings beginning with `autovacuum_` and adjust them according to the [PostgreSQL documentation on the autovacuum daemon](https://www.postgresql.org/docs/current/routine-vacuuming.html#AUTOVACUUM).
  </Step>

  <Step title="Restart the PostgreSQL database">
    Restart the PostgreSQL database service for the changes to take effect. Configuration changes to `postgresql.conf` are read at PostgreSQL start.
  </Step>
</Steps>

<Warning>
  Restarting the PostgreSQL database disconnects the Syteca Application Server briefly. Plan the restart during a maintenance window when active Client recording can be paused, or accept a brief interruption to Session data ingest while the database service restarts.
</Warning>

## Recreate the ActivityDB database and attach it as an archived database

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

<Steps>
  <Step title="Log in to the Application Server computer">
    Log in to the machine where Syteca Application Server is installed.
  </Step>

  <Step title="Stop the Application Server">
    Stop the **EkranServer** service.
  </Step>

  <Step title="Restart the database service">
    Restart your database service to close all existing connections to it.
  </Step>

  <Step title="Rename the existing ActivityDB database">
    <Tabs>
      <Tab title="MS SQL Server">
        In SQL Server Management Studio, expand **Databases**, right-click `EkranActivityDB`, select **Rename**, and enter a new name.
      </Tab>

      <Tab title="PostgreSQL">
        In pgAdmin4, check for existing connections to `EkranActivityDB`:

        ```sql theme={"system"}
        SELECT * FROM pg_stat_activity;
        ```

        Close any existing connections:

        ```sql theme={"system"}
        SELECT pg_terminate_backend(<pid>);
        ```

        Replace `<pid>` with the value shown for `EkranActivityDB`. Then rename the database:

        ```sql theme={"system"}
        ALTER DATABASE "EkranActivityDB" RENAME TO "newDBname";
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Restart the database service again">
    Restart the database service now that the rename is complete.
  </Step>

  <Step title="Start the Application Server">
    Start the **EkranServer** service. Since the original `EkranActivityDB` was renamed, Syteca creates a new, empty `EkranActivityDB` under the original name.
  </Step>

  <Step title="Connect the renamed database as an archived database">
    Log in to the Management Tool, open **Configuration > Database Management**, and connect the renamed database as an archived investigated database. See [Archived Sessions](/docs/session-monitoring/archived-sessions) for how archived databases are viewed afterward.
  </Step>
</Steps>

## Vacuum the PostgreSQL database manually

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

<Steps>
  <Step title="Log in to pgAdmin">
    Open pgAdmin and connect to the PostgreSQL server.
  </Step>

  <Step title="Stop the Application Server">
    Stop the **EkranServer** service in Windows Services.
  </Step>

  <Step title="Run a full vacuum">
    Right-click `EkranActivityDB`, select **Maintenance > Vacuum > Full**, and click **OK**.
  </Step>

  <Step title="Restart the Application Server">
    Once the vacuum completes, restart the **EkranServer** service.
  </Step>
</Steps>

<Tip>
  For recurring maintenance instead of a one-time manual vacuum, see [PostgreSQL autovacuuming](/docs/administration/deployment/database-management#postgresql-autovacuuming).
</Tip>

## How long do cleanup operations take?

Cleanup and Archive & Cleanup duration depends on how many sessions are in the database, their size, and where the archive instance is located.

As a rough estimate: archiving a session whose screen captures are stored in the database takes 3 to 6 minutes; a session whose screen captures are stored in a shared folder takes under a minute.

<Note>
  **IN SAAS ONLY:** only the **Cleanup** operation is available — **Archive & Cleanup** isn't offered in SaaS.
</Note>

## Upgrade from an older MS SQL Server version

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

To move a Syteca database from an older MS SQL Server version (for example 2008 R2) to a newer one, back it up on the old server and restore it on the new one using SQL Server Management Studio (SSMS). This procedure applies to any older-to-newer MS SQL Server version transfer.

<Steps>
  <Step title="Connect to the source server">
    In SSMS, click **Connect > Database Engine**, and enter the credentials for the source MS SQL Server.
  </Step>

  <Step title="Back up the database">
    In **Object Explorer**, right-click the required database (for example `SERVER.EkranManagementDatabase`), select **Tasks > Back Up**.
  </Step>

  <Step title="Set the backup location">
    Click **Add**, then the **...** button, choose a location and file name, and click **OK**.

    <Note>
      Note the backup location — you'll need it in a later step.
    </Note>
  </Step>

  <Step title="Connect to the destination server">
    Connect to the destination MS SQL Server the same way as in step 1.
  </Step>

  <Step title="Create a new database with the same name">
    Right-click **Databases**, select **New Database**, and enter the exact same database name as the one backed up.
  </Step>

  <Step title="Restore from the backup">
    Right-click the new database, select **Tasks > Restore > Database**. Under **Source**, select **Device**, click the **...** button, **Add**, and select the backup file.
  </Step>

  <Step title="Relocate the database files">
    On the **Files** page of the restore dialog, select **Relocate all files to folder**.
  </Step>

  <Step title="Allow overwriting">
    On the **Options** page, select **Overwrite the existing database (WITH REPLACE)**.
  </Step>

  <Step title="Complete the restore">
    Click **OK**. A confirmation message appears once the restore succeeds.
  </Step>
</Steps>

<Frame caption="Relocating database files during restore in SQL Server Management Studio.">
  <img src="https://mintcdn.com/syteca/0FlD-vkHsBA1azVX/images/administration/deployment/ms-sql-restore-relocate-files.png?fit=max&auto=format&n=0FlD-vkHsBA1azVX&q=85&s=206173229ba346a03ce5dc8d71ecc077" alt="SSMS restore dialog Files page with Relocate all files to folder selected" width="1511" height="770" data-path="images/administration/deployment/ms-sql-restore-relocate-files.png" />
</Frame>

## Shrink the MS SQL database transaction log

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

<Steps>
  <Step title="Open Database Management">
    Log in to the Management Tool as a user with the [administrative Database Management permission](/docs/administration/users/administrative-permissions), click **Configuration**, then select the **Database Management** tab.
  </Step>

  <Step title="Shrink the log">
    Click **Shrink Transaction Log** at the bottom of the page.
  </Step>
</Steps>

<Note>
  No progress indicator is shown, and there's no notification when shrinking completes.
</Note>

<Warning>
  Not supported if the MS SQL database is part of an SQL availability group — the System Health page explains why in that case. Shrinking also can't run while a database cleanup is already in progress.
</Warning>

## Set up hash-code calculation for monitoring data validation

<Warning>
  **NOT AVAILABLE IN SAAS.** Contact your Syteca vendor or the Syteca Support team to enable this in a SaaS environment.
</Warning>

This enables the hash-code option described in [Validate monitoring data integrity](#validate-monitoring-data-integrity) above — a lighter-weight alternative to certificate signing.

<Tabs>
  <Tab title="Version 6.53.1 and later">
    <Steps>
      <Step title="Stop the Application Server">
        Right-click the **Syteca Server** tray icon and select **Stop**, or stop the **EkranServer** service via Task Manager.
      </Step>

      <Step title="Add the key to the config file">
        Open `EkranServer.Settings.config` (by default in `C:\Program Files\Ekran System\Ekran System\Server`) and add:

        ```xml theme={"system"}
        <add key="SignMonitoredData" value="1" />
        ```
      </Step>

      <Step title="Start the Application Server">
        Start the **EkranServer** service again.
      </Step>
    </Steps>
  </Tab>

  <Tab title="Versions before 6.53.1">
    <Steps>
      <Step title="Stop the Application Server">
        Right-click the **Syteca Server** tray icon and select **Stop**, or stop the **EkranServer** service via Task Manager.
      </Step>

      <Step title="Set the registry value">
        Open Windows Registry Editor, select `HKEY_LOCAL_MACHINE\SOFTWARE\EkranSystem`, and add a new **DWORD (32-bit)** value named `SignMonitoredData` with data `1`.
      </Step>

      <Step title="Start the Application Server">
        Start the **EkranServer** service again.
      </Step>
    </Steps>

    <Note>
      After updating to version 6.53.1 or later, this setting moves from the registry to `EkranServer.Settings.config` automatically, and further changes must be made in that file.
    </Note>
  </Tab>
</Tabs>

## Set up certificate signing for monitoring data validation

<Warning>
  **NOT AVAILABLE IN SAAS.** Contact your Syteca vendor or the Syteca Support team to enable this in a SaaS environment.
</Warning>

This completes the certificate-signing option described in [Validate monitoring data integrity](#validate-monitoring-data-integrity) above. Do the following on the Application Server computer.

### 1. Import a trusted certificate

<Steps>
  <Step title="Open the Certificates snap-in">
    Press **Windows+R**, enter `mmc`, press **Enter**, and click **Yes** on the User Account Control prompt. Select **File > Add/Remove Snap-in**, choose **Certificates**, and click **Add**.
  </Step>

  <Step title="Target the local computer account">
    Select **Computer account**, click **Next**, select **Local computer: (the computer this console is running on)**, and click **Finish**, then **OK**.
  </Step>

  <Step title="Import the certificate">
    Under **Certificates (Local Computer)**, right-click **Personal**, select **All Tasks > Import**, and step through the Certificate Import Wizard: browse to the certificate file, enter its private key password if prompted, and finish the wizard.
  </Step>

  <Step title="Copy the certificate's thumbprint">
    Under **Certificates (Local Computer) > Personal > Certificates**, double-click the imported certificate, select **Details > Thumbprint**, and copy the value shown.
  </Step>
</Steps>

### 2. Enable signing with the certificate

<Tabs>
  <Tab title="Version 6.53.1 and later">
    <Steps>
      <Step title="Stop the Application Server">
        Right-click the **Syteca Server** tray icon and select **Stop**, or stop the **EkranServer** service via Task Manager.
      </Step>

      <Step title="Add the key to the config file">
        Open `EkranServer.Settings.config` (by default in `C:\Program Files\Ekran System\Ekran System\Server`) and add:

        ```xml theme={"system"}
        <add key="SignMonitoredDataCert" value="<copied Thumbprint value, no spaces>" />
        ```
      </Step>

      <Step title="Start the Application Server">
        Start the **EkranServer** service again.
      </Step>
    </Steps>
  </Tab>

  <Tab title="Versions before 6.53.1">
    <Steps>
      <Step title="Stop the Application Server">
        Right-click the **Syteca Server** tray icon and select **Stop**, or stop the **EkranServer** service via Task Manager.
      </Step>

      <Step title="Set the registry value">
        Open Windows Registry Editor, select `HKEY_LOCAL_MACHINE\SOFTWARE\EkranSystem`, and add a new **String Value** named `SignMonitoredDataCert` with the copied Thumbprint value (no spaces) as its data.
      </Step>

      <Step title="Start the Application Server">
        Start the **EkranServer** service again.
      </Step>
    </Steps>

    <Note>
      After updating to version 6.53.1 or later, this setting moves from the registry to `EkranServer.Settings.config` automatically, and further changes must be made in that file.
    </Note>
  </Tab>
</Tabs>

## Delete the PostgreSQL database manually

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

If the PostgreSQL database wasn't removed automatically when the Application Server was uninstalled, delete it manually. Only the database owner or a superuser can do this.

<Warning>
  Deleting a database can't be undone.
</Warning>

<Steps>
  <Step title="Restart the PostgreSQL server">
    Restart the PostgreSQL server before deleting the database.
  </Step>

  <Step title="Open pgAdmin">
    Start **pgAdmin** and connect to the server.
  </Step>

  <Step title="Select the databases to delete">
    In the **Browser** pane, select the database to delete. By default, Syteca uses two databases:

    * `ekranactivitydb`
    * `ekranmanagementdatabase`
  </Step>

  <Step title="Delete each database">
    Right-click each database and select **Delete/Drop**, then click **OK** to confirm.
  </Step>
</Steps>

## Validate monitoring data integrity

<Warning>
  **NOT AVAILABLE IN SAAS.** Contact your Syteca vendor or the Syteca Support team to enable this in a SaaS environment.
</Warning>

Monitoring data validation confirms that screen captures and metadata received from Windows Clients haven't been altered in the database. It's available for both PostgreSQL and MS SQL Server.

Two validation types are available:

* **Calculate hash codes** — a hash is calculated for each screen capture and metadata record received.
* **Sign with a certificate** — each screen capture and metadata record is signed with a trusted certificate.

<Note>
  If both are enabled, only certificate signing is actually used.
</Note>

<Warning>
  Enabling validation, or changing the validation type, invalidates every previously recorded Windows Client session.
</Warning>

Once enabled, opening a Windows Client session in the Session Player checks the integrity of its data. If any screen captures or metadata records were deleted or modified, the Session Player displays **"Session data is not valid!"**

<Note>
  Enabling validation increases CPU usage while viewing sessions in the Session Player. Screen captures won't display for existing sessions that hadn't been viewed before validation was enabled.
</Note>

## Isolate the database from Clients

<Warning>
  **NOT AVAILABLE IN SAAS.**
</Warning>

Isolation mode temporarily disconnects every Client from the database, useful when fixing database issues, running cleanup, or performing maintenance. While isolated, Clients keep monitoring and write data to their local cache until reconnected.

<Note>
  Only available to users of the built-in default tenant with the [administrative Tenant Management and System Configuration permission](/docs/administration/users/administrative-permissions) — for example, members of the Administrators user group.
</Note>

<Steps>
  <Step title="Open System Health">
    Click **System Health**, then the drop-down next to the **System State** tab.
  </Step>

  <Step title="Enable isolation">
    Select **Isolate Database from Clients**.
  </Step>
</Steps>

While enabled, every Client operates offline and writes to its local cache. Data flows to the Application Server automatically as soon as isolation is disabled.

<Steps>
  <Step title="Open System Health">
    Click **System Health**, then the drop-down next to the **System State** tab.
  </Step>

  <Step title="Disable isolation">
    Select **Stop Isolating Database from Clients** (or click the **here** link in the notification banner shown at the top of every page while isolation is active).
  </Step>
</Steps>

<Warning>
  After a long isolation period, disabling it causes a network load spike as every Client sends its accumulated offline data at once.
</Warning>

## Related

<CardGroup cols={2}>
  <Card title="Application Server troubleshooting" icon="wrench" href="/docs/resources/troubleshooting/application-server-troubleshooting">
    Diagnose Application Server issues, including database connection loss and Management Tool availability errors.
  </Card>

  <Card title="Application Server resource monitoring" icon="chart-line" href="/docs/administration/dashboards/application-server-monitoring">
    Watch the database write queue and storage usage in real time from the System State page.
  </Card>

  <Card title="System requirements" icon="server" href="/docs/get-started/system-requirements">
    Database sizing, supported PostgreSQL and MS SQL versions, and network port requirements.
  </Card>

  <Card title="Shared storage HA" icon="hard-drive" href="/docs/administration/deployment/shared-storage-ha">
    Move screen captures out of the database to shared storage, reducing database growth substantially.
  </Card>
</CardGroup>
