Docs / Managed databases

Managed databases

PostgreSQL or MariaDB that keeps running even if one server or one location goes down. It runs on your own servers, with any provider, and you only have to look after the database itself.

Concept: 2 data servers + 1 witness

A database cluster is made of three of your servers that are already connected to Saka:

RoleContentsJob
Data server 1Full databasePrimary or replica.
Data server 2Full databaseReplica or primary.
WitnessNo dataTakes part in electing the primary, so there are never two primaries when servers lose contact (no split data). Can be a small server.

Choose three different servers, ideally in three different locations (for example Singapore, Jakarta, and one more). One server may be the witness for many clusters (e.g. one small witness VM for dozens of customers; each cluster gets its own network and port), but a data server serves one cluster only. The servers are linked through an encrypted private WireGuard network created by the agent. Each server's WireGuard private key is generated on that server and never leaves it.

Latency between your app and the database matters. Place your app close to one of the data locations. In testing, a TLS connection from Sydney to Bangalore took ±3.8 seconds, so Saka connection strings use connect_timeout=5.

PostgreSQL 18/17 or MariaDB 12.3/10.11

PostgreSQL 18/17MariaDB 12.3/10.11
TechnologyPatroni + etcdGalera + garbd (witness)
Best forNew appsWordPress, Laravel, PHP apps (MySQL-compatible)
WriterOne primary, one replicaThe first healthy data node becomes the writer, the other node is the standby writer
Replication modeAsynchronous or synchronous (your choice)Always synchronous
Port54323306
Initial userpostgresroot
TLSRequired (hostssl, SCRAM)Required (require_secure_transport)

PostgreSQL 18 is the default for new clusters; choose 17 if your app doesn't support 18 yet. The version can't be changed after the cluster is created, and existing clusters stay on 17. In testing with the primary server forcibly powered off, PostgreSQL 18 failed over in 29 seconds without losing data (synchronous mode).

MariaDB 12.3 is the default; choose 10.11 (LTS until 2028) for older apps with an old MySQL client library, e.g. Ruby 2.5 or PHP 7 on Debian 10 images. That library (libmariadb 3.1) reads every text value as the number 0 from MariaDB 11.4 and newer; in testing, 10.11 is correct.

A PostgreSQL cluster is usually ready in ±30 seconds to 5 minutes; MariaDB is built one node at a time (±1.5 minutes in testing). You are notified on Telegram when it is ready or if it fails.

Replication mode (PostgreSQL)

MariaDB Galera is always synchronous: every write is confirmed by both data locations before it completes.

Create a cluster

  1. Add at least three servers to Saka (see Getting started). All of them must be connected.
  2. Open Database, press + Buat klaster database (Create database cluster).
  3. Choose the engine, two data servers, one witness server, the replication mode, and a name (lowercase letters, numbers, hyphens, 3-31 characters, starting with a letter).
  4. Follow the creation steps on the detail page.

Connection string & password

The cluster detail page shows the connection string. The password is not shown automatically: press Tampilkan sandi (Show password). The password is read directly from your data server at that moment; Saka does not store it. The password is generated when the cluster is created, passed once to the data servers, and then forgotten by Saka.

PostgreSQL: multi-host connection string

The string includes both data locations. Drivers that support multiple hosts (libpq, JDBC, Go pgx) automatically connect to the primary:

.env
DATABASE_URL=postgresql://postgres:[email protected]:5432,198.51.100.20:5432/postgres?sslmode=require&target_session_attrs=read-write&connect_timeout=5

MariaDB: direct connection string

.env
DATABASE_URL=mysql://root:[email protected]:3306/?ssl=true

This direct string points to one node only. To have your app follow along when a server goes down, use the Saka proxy (below).

Proxy on your app server

PHP (mysqlnd) and Node.js (mysql2, node-postgres) drivers cannot switch to another address on their own. In testing, the PHP client kept trying the first address until it timed out, and the Node client hung without an error. That is why Saka provides Sambungkan server aplikasi (Connect app server):

PostgreSQL via proxy
DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres?sslmode=require
MariaDB via proxy
DATABASE_URL=mysql://root:[email protected]:3306/?ssl=true

Examples used in testing (the MariaDB certificate is generated automatically, so certificate verification is turned off; the connection is still encrypted):

PHP (mysqli)
$m = mysqli_init();
$m->real_connect('127.0.0.1', 'root', $sandi, 'nama_db', 3306, null,
  MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
Node.js (mysql2)
mysql.createConnection({ host: '127.0.0.1', user: 'root', password: sandi,
  database: 'nama_db', ssl: { rejectUnauthorized: false } })
Laravel .env example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=nama_database_anda
DB_USERNAME=root
DB_PASSWORD=SANDI

TLS is required on both engines: the server rejects connections without TLS. The proxy passes connections through as they are, so turn on TLS in your driver (for example sslmode=require for PostgreSQL). Database certificates are generated on your own servers, not issued by a public CA.

The proxy can be removed from an app server at any time; the app on that server will then need a different connection string.

Database users (MariaDB)

One database is often used by two parties with different needs: an app that must write, and an analytics team that only needs to read. Instead of sharing the root account, create separate accounts in the Database users card on the MariaDB cluster detail page.

  1. Create a database (a new cluster starts empty): enter a name (letters, digits, underscore, up to 64 characters) and press Create database. The empty database appears on every node at once, and can also be filled by an import or a site.
  2. Create a user: enter a name (lowercase letters, digits, underscore; 3 to 32 characters), pick the database, then pick the access:
    • Read only: SELECT and viewing views only. Safe for analytics and reports; it cannot change or delete data or list accounts.
    • Full write: all rights on that one database (read, write, change table structure). For applications. Other databases and accounts stay closed.
  3. Save the password: Saka generates it and shows it only once. Saka does not store it. If it is lost, press New password; the old one stops working immediately.

A user can be switched between read only and full write at any time (it applies to the next connection), given a new password, or deleted. Deleting a user never touches the database or its data. Because the cluster is Galera, an account created is valid on both data nodes at once. SSL is required for every account; connect with the address and port in the Connection card, e.g. mariadb -h ADDRESS -P PORT -u analyst -p --ssl.

This card only manages accounts created through Saka. root, site accounts, and accounts you create yourself through root are not shown and not touched. For PostgreSQL, create roles through psql with the superuser password.

Move an existing database into the cluster

Have an existing PostgreSQL, MySQL 8, or MariaDB, e.g. on the same VM as its app? PostgreSQL moves into a PostgreSQL cluster, MySQL/MariaDB into a MariaDB cluster. On the cluster page, card Move an existing database into the cluster:

  1. Stop the old app so no new transactions happen during the copy.
  2. Choose the server where the old database lives (it must be connected to Saka), paste its address as seen from that server, e.g. postgresql://user:[email protected]:5432/db_name, and optionally a target database name (default: the same).
  3. Press Copy to cluster. Saka installs the proxy on that server, runs pg_dump into the cluster in a single transaction, and compares the row count of every table on both sides.

Import owner and recover node. PostgreSQL import accepts pemilik (the name of an app account already created in the cluster): the database and every schema, table, sequence, view, function and type in it are owned by that account instead of the superuser. Objects owned by extensions are left alone. If cluster containers are stopped on one node (for example a manual docker stop), start them with POST /api/v1/database/<id>/node/<server>/pulihkan or the MCP tool database_pulihkan_node: etcd, database, then proxy, without changing data.

Guided move (app on a server, with rollback)

For an app that runs as a systemd service and reads its database address from an env file, choose the source From env file, enter /path/file.env and the variable name, then open Guided move and enter the service name (and a health-check address if you have one). Saka then:

  1. stops the service (the app is down while the data is copied; you confirm first),
  2. copies the database in one transaction and compares row counts,
  3. rewrites the variable in the env file to the cluster address (the old file is kept beside it),
  4. starts the service and checks the app is healthy.

If any step fails after the service was stopped, the env file is restored and the service started again, so the app is back on the old database, which was only ever read. The password never passes through the panel or chat. MCP: database_pindahkan_lama with layanan.

Backups & point-in-time restore

A cluster that survives a server outage still needs backups: data deleted or damaged by mistake is copied to every location too. On the cluster page, card Backups & point-in-time restore:

  1. Create an empty bucket at your own S3 provider (Amazon S3, Cloudflare R2, DigitalOcean Spaces, Wasabi, or compatible).
  2. Press Turn on backups to S3 and fill in the endpoint (host name only), bucket, access key, secret key, and retention (default 14 days).
  3. Save the recovery code shown once. Backups in S3 are encrypted with it; if every cluster server is lost, it is the only way to open them.

Automatic restore test & alarms

A backup that has never been restored is only a hope. Every week (early morning, Western Indonesia time, on a replica when there is one) Saka restores the newest backup from S3 into a temporary copy, counts the tables in every database and compares with the live database, reports on Telegram, and deletes the copy. The live database is only read. Test restore now on the Backup tab runs it any time.

Fencing

The agent on each data server checks database health every 2 seconds. If a node is not fit to accept writes, its database port is closed to outside traffic with a TCP RST, so clients or the proxy immediately move to another node:

Traffic from the cluster's private network and from the server itself is not blocked.

Failover & self-healing

If the primary server goes down, the replica in another location takes over automatically. You are notified on Telegram when the primary moves, when no replica is in sync (the cluster temporarily cannot survive losing one server), and when a replica is in sync again.

Test (28 Sep 2026)Time until the app could write againRows lost
MariaDB, writer node killed suddenly, PHP and Node clients via proxy±11 seconds0
PostgreSQL product test, writer node killed suddenly, client via proxy33 seconds0
PostgreSQL proof of concept, asynchronous mode38.6 seconds0
PostgreSQL proof of concept, synchronous mode32.0 seconds0

The primary is elected among your own servers (etcd or garbd on all three servers). Saka Panel is not part of that path, so failover keeps working even if Saka Panel is down.

Add, release, and make primary

A running PostgreSQL cluster can be changed without stopping your apps:

Delete a cluster

Delete it from the cluster detail page by typing the cluster name to confirm. All data in this database, in every location, is deleted and cannot be undone. The proxy on app servers is removed as well. A server that cannot be reached at that moment keeps the leftovers until that server is released.

A cluster that is still the database of a site can't be deleted. Delete that site or move it to a server with a local database first.

Coming soon

Database branches per pull request, and a button to bring tables back from a copy into the cluster.