# Overview

Source: https://docs.interop.io/manager/databases/overview/index.html

## Overview

**io.Manager** supports connecting to [MongoDB](https://docs.interop.io/manager/databases/mongo/index.md), [PostgreSQL](https://docs.interop.io/manager/databases/postgresql/index.md) and [Microsoft SQL Server](https://docs.interop.io/manager/databases/microsoft-sql/index.md) databases.

The minimum required versions of the supported databases are as follows:
- Any supported version of MongoDB - (7, 8);
- Any supported version of PostgreSQL - (14, 15, 16, 17, 18);
- Any supported version of Microsoft SQL Server - (2016 SP3, 2017, 2019, 2022, 2025);

> ℹ️ *For complete examples of connecting **io.Manager** to the supported databases, see the [**io.Manager** Examples](https://github.com/InteropIO/manager-examples) repository on GitHub.*

## Database Size Management

**io.Manager** has a built in data purging (cleanup) functionality to help keep the database size proportional to the number of users and features used.

By default, the data purging operation is performed at server startup and at 24-hour intervals after that. To prevent unnecessary database operations, the periodic cleanup is synchronized between multiple server nodes connected to the same database.

Purging is supported for the following pieces of data:

- Inactive sessions and machine information
- Commands and command results
- Feedback reports
- Crash reports
- Audit logs

Data purging is enabled by default and can be configured via the configuration object for initializing the **io.Manager** Server, or via environment variables, depending on your [deployment](https://docs.interop.io/manager/deployment/index.md) approach.

### Environment Variables

To configure the data purging process, register the following environment variables with the proper values:

| Environment Variable | Description |
|----------------------|-------------|
| `API_PURGE_AT_STARTUP_ENABLED` | If `true` (default), the data purging operation will be performed on startup of the **io.Manager** Server. *Available since **io.Manager** Server 1.7.* |
| `API_PURGE_AUDIT_LOGS_AFTER_DAYS` | Number of days after which an audit log becomes eligible for purging. Set to `-1` to disable purging of audit logs. Defaults to `90`. |
| `API_PURGE_COMMANDS_AFTER_DAYS` | Number of days after which an executed command and the respective command result become eligible for purging. Set to `-1` to disable purging of commands and command results. Defaults to `90`. *Available since **io.Manager** Server 2.0.* |
| `API_PURGE_CRASH_REPORTS_AFTER_DAYS` | Number of days after which a crash report becomes eligible for purging. Set to `-1` to disable purging of crash reports. Defaults to `90`. |
| `API_PURGE_ENABLED` | If `true` (default), will enable data purging. |
| `API_PURGE_FEEDBACK_REPORTS_AFTER_DAYS` | Number of days after which a feedback report becomes eligible for purging. Set to `-1` to disable purging of feedback reports. Defaults to `90`. |
| `API_PURGE_INACTIVE_SESSIONS_AFTER_DAYS` | Number of days of inactivity after which a session becomes eligible for purging. All machine entries that aren't referenced by any sessions will also be purged. Set to `-1` to disable purging of sessions and machine information. Defaults to `90`. |
| `API_PURGE_SCHEDULED_TASK_INTERVAL` | Interval in milliseconds at which to run the periodic data purging operation. Defaults to `86400000` (1 day). *Available since **io.Manager** Server 2.0.* |

The following example demonstrates how to disable purging on startup of the **io.Manager** Server and how to configure the purging intervals for some of the supported data entities:

```cmd
# Disabling purging on startup of the io.Manager Server.
API_PURGE_AT_STARTUP_ENABLED=false

# Configuring the inactivity period for sessions
# after which a session becomes eligible for purging.
API_PURGE_INACTIVE_SESSIONS_AFTER_DAYS=60

# Disabling purging for feedback reports.
API_PURGE_FEEDBACK_REPORTS_AFTER_DAYS=-1
```

### Configuration Object

To configure the data purging operation, use the `purge` top-level key of the optional `Config` object for initializing the **io.Manager** Server.

The following example demonstrates how to disable purging on startup of the **io.Manager** Server and how to configure the purging intervals for some of the supported data entities:

```javascript
import { start } from "@interopio/manager";

const config = {
    // Purging configuration.
    purge: {
        // Disabling purging on startup of the io.Manager Server.
        purgeAtStartupEnabled: false,
        // Configuring the inactivity period for sessions
        // after which a session becomes eligible for purging.
        purgeInactiveSessionsAfterDays: 60,
        // Disabling purging for feedback reports.
        purgeFeedbackReportsAfterDays: -1
    }
};

const server = await start(config);
```

The `purge` object has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `enabled` | `boolean` | If `true` (default), will enable data purging. |
| `purgeAtStartupEnabled` | `boolean` | If `true` (default), the data purging operation will be performed on startup of the **io.Manager** Server. |
| `purgeAuditLogsAfterDays` | `number` | Number of days after which an audit log becomes eligible for purging. Set to `-1` to disable purging of audit logs. Defaults to `90`. |
| `purgeCommandsAfterDays` | `number` | Number of days after which an executed command and the respective command result become eligible for purging. Set to `-1` to disable purging of commands and command results. Defaults to `90`. *Available since **io.Manager** Server 2.0.* |
| `purgeCrashesAfterDays` | `number` | Number of days after which a crash report becomes eligible for purging. Set to `-1` to disable purging of crash reports. Defaults to `90`. |
| `purgeFeedbackReportsAfterDays` | `number` | Number of days after which a feedback report becomes eligible for purging. Set to `-1` to disable purging of feedback reports. Defaults to `90`. |
| `purgeInactiveSessionsAfterDays` | `number` | Number of days of inactivity after which a session becomes eligible for purging. All machine entries that aren't referenced by any sessions will also be purged. Set to `-1` to disable purging of sessions and machine information. Defaults to `90`. |
| `scheduledTaskInterval` | `number` | Interval in milliseconds at which to run the periodic data purging operation. Defaults to `86400000` (1 day). *Available since **io.Manager** Server 2.0.* |
