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:
| Role | Contents | Job |
|---|---|---|
| Data server 1 | Full database | Primary or replica. |
| Data server 2 | Full database | Replica or primary. |
| Witness | No data | Takes 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/17 | MariaDB 12.3/10.11 | |
|---|---|---|
| Technology | Patroni + etcd | Galera + garbd (witness) |
| Best for | New apps | WordPress, Laravel, PHP apps (MySQL-compatible) |
| Writer | One primary, one replica | The first healthy data node becomes the writer, the other node is the standby writer |
| Replication mode | Asynchronous or synchronous (your choice) | Always synchronous |
| Port | 5432 | 3306 |
| Initial user | postgres | root |
| TLS | Required (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)
- Fast (asynchronous): writes as fast as a single server. If the primary dies suddenly, the last few seconds of transactions may be lost.
- No data loss (synchronous): every write waits for the second location. Slower by about one network round trip between locations (±38 ms between Singapore and Bangalore in testing). Good for money transactions.
MariaDB Galera is always synchronous: every write is confirmed by both data locations before it completes.
Create a cluster
- Add at least three servers to Saka (see Getting started). All of them must be connected.
- Open Database, press + Buat klaster database (Create database cluster).
- 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).
- 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:
DATABASE_URL=postgresql://postgres:[email protected]:5432,198.51.100.20:5432/postgres?sslmode=require&target_session_attrs=read-write&connect_timeout=5MariaDB: direct connection string
DATABASE_URL=mysql://root:[email protected]:3306/?ssl=trueThis 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):
- Saka installs a small HAProxy on the server where your app runs (a server registered with Saka). This can also be a cluster member, i.e. web app and database on the same VM: the proxy there checks the health of every node (PostgreSQL: Patroni; MariaDB: node Primary and Synced) and always leads to the same writer, never a lagging local node. See Survive a VM outage.
- The proxy listens on
127.0.0.1and forwards to a healthy data node. The other node is the backup. - While the primary switches, new connections are held until the new node is ready (up to about 30 seconds) instead of being refused. In a real failover test (the PostgreSQL primary server was shut down), one new connection was held for 28 seconds and then succeeded on the new primary, and only 2 of 233 attempts failed, within about 0.3 seconds while the old PostgreSQL was stopping and not yet detected; before, 53 of 570 attempts failed. Connections that are already open still drop at failover, so your app should still retry an in-flight transaction.
- Your app just connects to
127.0.0.1. The port is the same as the database port (5432 or 3306), or that port plus 10000 (15432 or 13306) if a local database already uses it.
DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres?sslmode=requireDATABASE_URL=mysql://root:[email protected]:3306/?ssl=trueExamples used in testing (the MariaDB certificate is generated automatically, so certificate verification is turned off; the connection is still encrypted):
$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);mysql.createConnection({ host: '127.0.0.1', user: 'root', password: sandi,
database: 'nama_db', ssl: { rejectUnauthorized: false } })DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=nama_database_anda
DB_USERNAME=root
DB_PASSWORD=SANDITLS 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.
- 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.
- Create a user: enter a name (lowercase letters, digits, underscore; 3 to 32 characters), pick the database, then pick the access:
- Read only:
SELECTand 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.
- Read only:
- 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:
- Stop the old app so no new transactions happen during the copy.
- 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). - Press Copy to cluster. Saka installs the proxy on that server, runs
pg_dumpinto the cluster in a single transaction, and compares the row count of every table on both sides.
- A failure midway leaves the cluster unchanged. The old database is only read, never modified.
- A target database that already has tables is not overwritten unless you tick Overwrite (its old contents in the cluster are dropped first).
- Errors name a fixable cause: password rejected, old database not answering,
pg_hba.confrefusing 127.0.0.1, old version newer than the cluster, or an unavailable extension. - The old database password is only passed to that server and is not stored. Time limit 2 hours; in testing, 200,500 rows took 3 seconds.
- MySQL 8 to MariaDB: address
mysql://user:[email protected]:3306/db_name.utf8mb4_0900_*collations are mapped to MariaDB equivalents, MyISAM becomes InnoDB, DEFINERs are dropped, and tables without a primary key are reported. MySQL DDL can't be rolled back, so on failure the target database it created is removed again. - API:
POST /api/v1/database/<id>/impor {"server_id", "sumber", "database", "timpa"}; MCP:database_pindahkan_lama.
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:
- stops the service (the app is down while the data is copied; you confirm first),
- copies the database in one transaction and compares row counts,
- rewrites the variable in the env file to the cluster address (the old file is kept beside it),
- 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:
- Create an empty bucket at your own S3 provider (Amazon S3, Cloudflare R2, DigitalOcean Spaces, Wasabi, or compatible).
- Press Turn on backups to S3 and fill in the endpoint (host name only), bucket, access key, secret key, and retention (default 14 days).
- 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.
- How it works: pgBackRest on the data servers streams every change (WAL) to S3 continuously, plus a weekly full and daily differential backup between 01:00 and 04:00 WIB from the primary. Saka stores neither the S3 keys nor the recovery code.
- Restore: press Restore to a point in time and pick a time down to the second (or the latest state). The result is a separate copy on one data server (127.0.0.1, cluster password). The running cluster is not touched, so you can check the contents first, take the tables you need, then delete the copy.
- Bring data back from a copy: press Bring data back on the copy. The panel lists every table with its row count in the copy and in the database now, and marks the ones that differ. Pick the tables, then how:
- Copy to a separate place (default, safe): the tables are copied into
pulih_<time>(PostgreSQL: a schema in the same database; MariaDB: a new database), without foreign keys. Current data is not touched; move the rows you need with SQL, e.g.INSERT INTO public.orders SELECT * FROM pulih_20261004_1030.orders WHERE id NOT IN (SELECT id FROM public.orders), or ask your AI agent. - Replace the current table contents: the tables get the copy's contents. The old contents are saved to
sebelum_<time>first; changes to those tables since the restore point are lost. PostgreSQL does it in a single transaction.
- Copy to a separate place (default, safe): the tables are copied into
- In testing (3 Oct 2026): 150 transactions were deliberately deleted from the cluster, and a copy at the second before the deletion held all 150 rows. Restore uses server time, so match against the server clock (not an unsynchronized device clock).
- MariaDB: a daily full backup (mariadb-backup) plus binlogs shipped to S3 every minute, so the latest restorable point lags by about 1-2 minutes at most (PostgreSQL is immediate). One data node is the backup node; if it dies another takes over and immediately makes its own full backup (in testing: 30 seconds after the backup node was powered off hard). When backups are turned on, nodes restart one at a time with binlogs on while the other keeps serving.
- In the MariaDB 10.11 test (3 Oct 2026): the backup was made in Singapore and restored in Bangalore; the copy before the deletion held all 150 rows, the copy at the earlier point 100.
- Older PostgreSQL clusters restart once when backups are first turned on (replica first; the primary may move for a few seconds).
- API:
POST /api/v1/database/<id>/cadangan,GET .../cadangan,POST .../cadangan/sekarang,POST .../pulihkan {"waktu", "nama"},GET .../salinan/<nama>/tabel,POST .../salinan/<nama>/ambil {"database", "tabel", "timpa"},DELETE .../salinan/<nama>. MCP:database_cadangan_status,database_pulihkan,database_salinan_tabel,database_salinan_ambil,database_salinan_hapus.
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.
- Telegram alarms when the first full backup does not appear (over 2 hours), the newest backup is older than 36 hours, or archiving WAL to S3 is failing. One message a day until fixed, and one more when it recovers.
- Fix moves a half-set-up backup to a fresh repository; Show recovery code reveals the encryption passphrase on demand.
- The agent refuses to start when the server lacks disk or RAM. MCP:
database_cadangan_status; API:POST /api/v1/database/<id>/cadangan/verifikasi.
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:
- PostgreSQL: only the Patroni leader is open, replicas are closed.
- MariaDB: open only when the node is Primary and Synced. A node that is rejoining stays closed until it is in sync.
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 again | Rows lost |
|---|---|---|
| MariaDB, writer node killed suddenly, PHP and Node clients via proxy | ±11 seconds | 0 |
| PostgreSQL product test, writer node killed suddenly, client via proxy | 33 seconds | 0 |
| PostgreSQL proof of concept, asynchronous mode | 38.6 seconds | 0 |
| PostgreSQL proof of concept, synchronous mode | 32.0 seconds | 0 |
- PostgreSQL: a server that went down comes back as a replica by itself when it is turned on (pg_rewind), with no manual steps.
- MariaDB: a server that went down copies data from another node when it comes back, then becomes a writer again.
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:
- Add a data server: Saka installs PostgreSQL there, joins it to the cluster's private WireGuard mesh, and copies the data from the primary. If S3 backups are already on, the backup configuration is copied too so backups continue if the new node becomes primary. MCP:
database_tambah_node. - Release a replica: a replica added this way can be released (the cluster data on that server is removed; the cluster keeps running). A server that died for good is released with a force option. The primary and the original (etcd) members cannot be released from here.
- Make primary (Advanced): planned switchover to another replica through Patroni; app proxies are updated first. MCP:
database_jadikan_utama. - Diagnose: read-only evidence of each node (containers, WireGuard handshakes, firewall, ports, logs without passwords, the Patroni view) with a guess at the problem. MCP:
database_diagnosa. - Replication mode & outside access (Advanced): switch between synchronous and asynchronous, and allow specific IP addresses to reach the database port through the node firewall. Nothing is open to the internet by default. MCP:
database_ubah_mode,database_akses. - Network pre-check: before creating a cluster, the Readiness section on the Servers page tests UDP/TCP between servers and the round-trip time, so a provider firewall that blocks the tunnel is found first. MCP:
jaringan_periksa.
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.
Database branches per pull request, and a button to bring tables back from a copy into the cluster.