Skip to main content

Database

Termix uses SQLite by default. There is nothing to set up, and it is the right pick for one Termix server.

Use PostgreSQL or MySQL when you want the data on a database server you already run and back up, or when you run more than one Termix server against the same data.

Plugins keep their tables in the same database, so this one setting covers everything.

Settings​

VariableDefaultWhat it does
DATABASE_DIALECTsqlitesqlite, postgres or mysql.
DATABASE_URLConnection URL for postgres or mysql, like postgres://user:pass@db:5432/termix.
DATABASE_POOL_MAX10Most connections Termix opens to postgres or mysql.
DATABASE_SSLTLS for postgres or mysql: require, no-verify or disable.
DB_FILE_ENCRYPTIONtrueEncrypt the SQLite file at rest. Set false only if something else already encrypts the disk.
DB_FILE_KEYOnly used to open SQLite files encrypted by very old versions. You almost never need it.
DATABASE_LAYER_SKIP_PREUPGRADE_BACKUPfalseSkip the backup Termix takes of the data folder before an upgrade changes the database.
DATABASE_LAYER_PREUPGRADE_BACKUP_KEEP3How many of those upgrade backups to keep.

PostgreSQL​

docker-compose.yml
services:
termix:
image: ghcr.io/termix-ssh/termix:latest
container_name: termix
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- termix-data:/app/data
environment:
PORT: "8080"
DATABASE_DIALECT: "postgres"
DATABASE_URL: "postgres://termix:change-me@postgres:5432/termix"
depends_on:
- postgres

postgres:
image: postgres:17
restart: unless-stopped
environment:
POSTGRES_USER: termix
POSTGRES_PASSWORD: change-me
POSTGRES_DB: termix
volumes:
- postgres-data:/var/lib/postgresql/data

volumes:
termix-data:
postgres-data:

DATABASE_URL takes postgres:// or postgresql://. Termix makes and updates its tables itself, so the user needs rights to create tables in its database.

If you use a database server you already have:

CREATE DATABASE termix;
CREATE USER termix WITH PASSWORD 'change-me';
GRANT ALL PRIVILEGES ON DATABASE termix TO termix;

MySQL and MariaDB​

docker-compose.yml
services:
termix:
image: ghcr.io/termix-ssh/termix:latest
container_name: termix
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- termix-data:/app/data
environment:
PORT: "8080"
DATABASE_DIALECT: "mysql"
DATABASE_URL: "mysql://termix:change-me@mysql:3306/termix"
depends_on:
- mysql

mysql:
image: mysql:8.4
restart: unless-stopped
environment:
MYSQL_USER: termix
MYSQL_PASSWORD: change-me
MYSQL_DATABASE: termix
MYSQL_ROOT_PASSWORD: change-me-too
volumes:
- mysql-data:/var/lib/mysql

volumes:
termix-data:
mysql-data:

DATABASE_URL takes mysql:// or mariadb://.

CREATE DATABASE termix;
CREATE USER 'termix'@'%' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON termix.* TO 'termix'@'%';

TLS to the database​

DATABASE_SSL is off unless you set it.

ValueWhat it does
requireEncrypt and check the server's certificate.
no-verifyEncrypt, but don't check the certificate. For a self-signed one on a private network.
disableNo TLS. Same as not setting it.

Any other value stops Termix at startup, so a typo can't quietly turn TLS off.

Keep the data volume​

Even on PostgreSQL or MySQL, keep the /app/data volume. It holds the keys that decrypt your passwords and SSH keys, plus plugins, certificates and recordings.

Move an existing install​

  1. On the old install, open Settings, Database and press Export Database. You get a portable .sqlite file.
  2. Start a new install on the new database.
  3. Make the admin account, open Settings, Database and import the file.

The export has your secrets in it, decrypted. Delete it when you are done.

Encryption​

Passwords, keys and other secrets are encrypted before they are written, on every database.

DB_FILE_ENCRYPTION is extra. It encrypts the whole SQLite file on disk, so it only applies to SQLite. On PostgreSQL or MySQL, keep the server on a private network, give Termix its own user, and use DATABASE_SSL if the network isn't yours.

The desktop app​

The desktop app's own server always uses SQLite. It can still link to a server that uses PostgreSQL or MySQL. See desktop sync.