Core
Databases & backups
The complete upstream guide to databases & backups, synchronized with the product repository.
Product v0.22.0 · Complete source guide
Managed Databases & Backups
NineDeploy provides provisioning and lifecycle management for databases, encrypted database dumps, and attached-volume snapshots with offsite cloud storage.
🗄️ 1. Supported Managed Databases
| Engine | Default version / Flavor | Features |
|---|---|---|
| PostgreSQL | 18, or pgvector (PostgreSQL 18) | Full ACID, vector embeddings, relational indexing |
| MySQL | 9.7 (set 8.0 or 8.4 for an LTS) | High throughput, InnoDB storage |
| MariaDB | 12.3 (set 11.4 or 11.8 for an LTS) | Community SQL server with columnar support |
| Redis / Valkey | Redis 8.8, Valkey 9.1 | Low-latency in-memory caching and message pub/sub |
| KeyDB | 6.3 (eqalpha/keydb) | Multithreaded Redis-compatible server (section 9) |
| Dragonfly | 1.x (ghcr.io/dragonflydb/dragonfly) | Multi-core Redis-compatible in-memory store (section 9) |
| MongoDB | 8.0 Community (pin 7.0 for the previous LTS) | Document-oriented NoSQL database; starts on Linux 6.19–7.0.13 too (below) |
| ClickHouse | 25.8 (clickhouse/clickhouse-server) | High-performance columnar analytics; backups since G1.8 (section 10) |
| Meilisearch | v1.53 (getmeili/meilisearch) | Full-text search engine; backups since G1.8 (section 10) |
| RabbitMQ | 4 Management (rabbitmq:4-management) | Message broker with AMQP; definitions backups since G1.8 (section 10) |
Every database keeps the version it was created with. version takes any tag the upstream image publishes. A database created without one is given the engine's default tag at creation, and keeps it when a later NineDeploy release moves that default: a newer server started on older data would upgrade it in place (MySQL, MariaDB), write files the old one cannot read (Redis) or refuse to start (PostgreSQL, Meilisearch). Section 12 moves a database to a newer release on purpose. Databases created before 0.18.28 without a version are pinned when the panel starts: each gets the tag of the image its container runs. A stopped database has no container (Stop removes it): it gets today's default when its volume does not exist yet or was created by today's default image, and on a node. The panel log names each one (database-version-pin). A database is left unpinned, and tried again at the next start, when Docker does not answer, when its container runs an image no tag of its engine reproduces, or when it is stopped and its volume was created by an older default (its data may or may not have been upgraded since, so neither tag is safe); it then follows the default as before, and the log says so. KeyDB's default depends on the CPU, so a stopped KeyDB database stays unpinned. Such a database is shown, and its release can be named before its first start: A database without a version.
MongoDB on Linux 6.19 through 7.0.13. MongoDB 8.0 refuses to start on these kernels with the mongo:8 image's own setting, glibc.pthread.rseq=0. The error is "Linux kernel versions 6.19 and newer has a known incompatibility" (SERVER-121912). The image's setting turns on TCMalloc's per-CPU caches, which crash there. NineDeploy starts MongoDB containers with GLIBC_TUNABLES=glibc.pthread.rseq=1, so TCMalloc uses per-thread caches, as in MongoDB 7. It starts on every kernel. Kernel 7.0.14 and later also fixes the incompatibility. An existing database picks the setting up the next time it is started (Stop, then Start); Restart keeps the container's old settings.
🔗 2. Connection String Auto-Injection
- When a database is provisioned, NineDeploy generates cryptographically strong random credentials.
- In-memory linkers automatically inject environment variables into linked application services:
DATABASE_URL(e.g.postgresql://user:pass@srv-postgres:5432/main)REDIS_URL(e.g.redis://:pass@srv-redis:6379)
☁️ 3. Offsite Backup Destinations
Automated backup jobs upload backups to S3-compatible cloud storage. Database dumps use streaming AES-256-GCM encryption:
- Amazon S3 / AWS GovCloud
- Cloudflare R2 (Zero egress fees)
- MinIO / Self-Hosted S3
- Wasabi / DigitalOcean Spaces
The same destination stores attached-volume snapshots as tar.gz archives encrypted with the same streaming AES-256-GCM envelope as database dumps; downloads and restores decrypt transparently, and legacy plaintext archives written before encryption keep restoring unchanged. Snapshots taken before the encryption change remain plaintext on disk until they age out of retention — restrict access to the backup directory and bucket accordingly. Each uploaded backup records which destination holds its object, so switching the active destination does not orphan earlier recovery points — restores and remote deletions resolve the bucket that actually holds the object (rows whose destination was deleted fall back to the active one).
Retention counts completed recovery points separately from failed attempts and leaves running backups untouched. Failed attempts cannot evict the last successful backups.
Without a backup policy (below), the scheduler backs each running database up once a day and keeps the seven newest completed scheduled dumps. A dump that falls out of that window is removed together with its remote copy: the remote object is deleted first, through the destination its record names, and the record only once that delete succeeded. A record whose destination is unknown or unreachable is kept and retried on a later run, at most 100 remote deletes per run (or two per database, if that is more).
🗓️ 3a. Per-database backup policy
Each database can have its own Backup schedule (Database → Backups tab, ninedeploy databases backup-policy, or GET/PUT /v1/databases/:id/backup-policy):
| Field | Meaning |
|---|---|
enabled | false turns scheduled backups off for this database. Manual snapshots still work. |
cron | A 5-field cron expression (minute hour day month weekday) in the server's local time, checked with the same rule as scheduled jobs. A 6-field (seconds) pattern is refused. The UI offers daily (0 3 * * *), every 6 hours (0 */6 * * *) and weekly (0 3 * * 0). |
retainCount | Completed scheduled dumps kept on the panel host, 1–365. |
retainRemoteCount | Optional, 1–365. Off-site copies kept, counted over the dumps that actually have one. If you leave it out, a dump's remote copy is removed with the dump (the built-in rule). If it is higher than retainCount, older dumps stay restorable from the bucket after their local file is pruned. If it is lower, newer dumps keep their local file and lose only the remote copy. |
destinationId | Optional. A specific backup destination for this database's scheduled dumps. Leave it out to use the active destination. Only an instance operator can choose a specific destination, because destinations are managed by operators. If that destination is deleted, the policy falls back to the active one. |
localOnly | true keeps this database's scheduled dumps on the panel host only. It cannot be combined with destinationId or retainRemoteCount. |
- Upgrades change nothing. Policies live in their own table (
database_backup_policies, migration 0067). A database with no policy row keeps the built-in schedule exactly: daily, seven kept, the active destination.GETreports such a database asconfigured: false. - Authorization: reading a policy follows the database (the same as listing its backups). Saving one needs
adminon the database, the same as taking a backup. Every save is audited asbackup.policy.update. - Applied at once: saving a policy re-arms that database's schedule immediately. The scheduler also resyncs every 15 minutes. A policy database is skipped by the built-in daily run.
- Retention safety: the newest completed dump, and the newest remote copy, are never pruned (both counts are at least 1). Failed attempts are bounded separately (seven kept) and can never evict a completed dump. Manual snapshots and running operations are never touched. A dump file still referenced by a kept record is never unlinked.
- Missed-backup alert: a database with a policy is judged against its own cadence (twice its interval, and never less than two days). A disabled policy is exempt.
- Scope: the policy governs scheduled dumps. "Backup now" still uploads to the active destination, and manual snapshots are only removed by hand.
Replica destinations (G3.3)
A database's scheduled dumps can also go to up to three more backup destinations, for a copy in a second region or provider. Set them under Database → Backups → Backup replicas, or with PUT /v1/databases/:id/backup-replicas and { "replicas": [{ "destinationId": 2, "retainCount": 14 }] }. Like naming a specific destination in the policy, this is for operators.
How copies are made
- After the main upload, the same encrypted dump is copied to each replica at
<prefix>/<file>. - Each replica keeps its own
retainCountnewest copies and deletes older ones there. A copy whose delete fails is tried again on the next run. - A failure at one replica is logged and shown on the card, and never fails the backup or the other replicas.
Limits
- Scheduled dumps only, and not for a local-only policy. Manual backups go to the active destination as before.
- Restores read from the main copy. A replica is for getting a dump back by hand when that destination is lost.
- Taking a destination off the list leaves its copies in the bucket.
Storage: no migration is needed. The list and the log of copies are one settings row per database, backup_replicas:<id>.
💾 4. Volume Snapshots & Labels
Each managed Docker volume can be snapshotted (tar.gz), restored or downloaded from the Volumes tab:
- Labels: manual snapshots accept an optional operator label (up to 40 chars, defaulting to
manual); scheduled runs are labeledschedule-YYYY-MM-DD. Labels surface on the Backups page so a mixed database/volume list stays readable. - Scheduling: a recurring job can sweep multiple volumes in one pass, reusing the backup destination for off-site copies.
- Safe restore: restores refuse to run while a service is still live on that volume.
Volumes on nodes
A volume lives on the host of the service that uses it. Volumes of a service placed on a node live on that node, and the volume routes take ?serverId=<node> to work with them (without it they act on the panel host, exactly as before). These features need the node agent v0.15.2 or newer, which advertises volume.manage, docker.runSpec and stream. An older agent gets 422 node_agent_outdated with an "update the node agent" message, and nothing else is sent to it.
- List and create:
GET /v1/volumes?serverId=lists the node's managed volumes.inUseis true while a running container on the node mounts the volume.POST /v1/volumes {name, serverId?}creates a managed volume (nd-svc-*/nd-db-*) labelledninedeploy.managed=volume. An existing volume answers409 node_volume_exists.DELETE /v1/volumes/:name?serverId=is unchanged. - Attachments, commands and the Docker socket on node docker services: these now deploy through the agent's structured
docker.runSpec. Any missing managed volume is created on the node first. An attached volume that a service or database on another host also uses is refused with409 attachment_host_mismatch, because each host has its own volume of that name. A database volume is never created by a service that attaches it. Bind mounts stay unattachable everywhere. - Compose stacks on nodes: missing attached volumes are now created before
compose up. Before this, a stack failed atcompose upwith "external volume not found" unless someone had created the volume on the node by hand. With an older agent nothing is created, and the volumes must already exist, as before. - Backups:
POST /v1/volumes/:name/backups?serverId=streams the volume from the node over the sealed stream channel. The backup lands in the same backups directory, with the same file name and format as a panel-host snapshot, encrypted at rest. The plaintext archive is never written to the panel's disk. It is uploaded off-site like any other backup. The row recordsserverId. Retention is counted per host, so node copies never push panel-host copies out. Scheduled backup jobs of a node service back its volumes up from the node. - Restore:
POST …/backups/:bid/restore?serverId=restores on the node through the same staging script, and refuses while any running container on the node mounts the volume. A backup taken on another host restores only with?acrossHosts=true. - Files: the file manager works on panel-host volumes only. With
?serverId=it answers422 node_volume_files_unsupportedrather than touching the panel host's volume of the same name. - Rollback to 0.15: node volumes stay on the node (
docker volume ls --filter label=ninedeploy.managed=volume). Node volume backups stay on the panel and can be downloaded, but a 0.15 restore writes into the panel host's volume of the same name, not into the node. Restore node volumes only after upgrading again.
🛡️ 5. Restore Safety
- Restores can be initiated via Web UI or CLI (
ninedeploy backups restore <databaseId> <backupId>). - Check a backup without restoring it. A drill runs the engine's own reader over the dump (for example
pg_restore --listorredis-check-rdb) in a throwaway container and recordspassed,failedorunverifiable(the check itself could not run, which says nothing about the file). Use Check on a backup row in the database's Backups tab, where the Last check column shows the newest verdict (web UI since G1.5),ninedeploy backups drill <databaseId> <backupId>, orPOST /v1/databases/:id/backups/drillandGET /v1/databases/:id/drills. A drill needsmemberon the database. It does not restore anything, so it proves the file is readable, not that the data is what you expect. - Verify a backup by restoring it (R3), for every engine. Verify restore in the Backups tab restores the backup into a throwaway container of the database's own engine image on the panel host and runs your query there. The CLI is
ninedeploy backups drill <databaseId> <backupId> --restore-query "SELECT count(*) FROM users" --expect 42; the API isPOST /v1/databases/:id/backups/drillwith{ backupId, restore: { query, expected } }.- Verdict:
passedonly when the client's output, without headers, equals the expected value exactly. Rows are on separate lines.- PostgreSQL: psql's unaligned output, with
|between columns. - MySQL and MariaDB: the client's batch output, with a tab between columns, values unescaped and NULL printed as
NULL. The query runs in theappdatabase, so qualify other schemas (SELECT count(*) FROM shop.orders). The whole--all-databasesdump is restored, including itsmysqlschema. - MongoDB: the query is a mongosh script, for example
db.getSiblingDB('shop').orders.countDocuments(). The expected value is what mongosh prints for its last expression;EJSON.stringify(…)prints one stable line. The whole archive is streamed intomongorestore --stopOnError. - ClickHouse: the query is SQL, and the expected value is
clickhouse-client's TabSeparated output: a tab between columns, and NULL printed as\N. The query runs in theappdatabase. The whole backup archive is restored withRESTORE ALL. - Meilisearch: the query is an API path, for example
/indexes/movies/documents/1?fields=title. The expected value is the JSON body a GET on that path returns. Search results carry a processing time, so documents and stats make stable probes. The dump is imported as the container starts. - RabbitMQ: the query is one
rabbitmqctllist command, for examplelist_queues -p shop name durable. The expected value is what it prints without headers: a tab between columns, one row per line, and rows compare in any order. The definitions export is imported, and the query waits until every vhost, queue, exchange and binding it names exists. A definitions backup holds no messages, so probe names and settings, not message counts. - Redis, Valkey, KeyDB and Dragonfly: the query is one command per line, for example
GET greeting. The expected value is what the command-line client prints: one line per value or list element, and an empty line for nil. The server loads the RDB backup as it starts. If it rejects the file (wrong signature, truncated or corrupt), the verdict isfailed. - Recovery duration: a verification records how long the real restore took (
restoreMsin the drill's details). The Backups tab shows it next to the verdict, and the CLI prints it on a pass. It measures the bounded container on the panel host, not a promise for a production restore. failedmeans the restore or the query really failed, or the data differs.unverifiablemeans the check could not run. Causes: the engine image could not be pulled, the container ran out of its bounds or its engine stopped, or the panel restarted mid-run. A backup larger than 512 MiB is refused up front, because the container has 1 GiB of scratch space for both the dump and the restored data.
- PostgreSQL: psql's unaligned output, with
- Isolation: the container has no network, no published ports and no host mounts. It runs with all capabilities dropped, a read-only root and tmpfs storage only, and it is removed afterwards. The live database is never touched. The query and expected value are not stored, logged or audited.
- Role: the probe tells you something about the backup's contents, so it needs
adminon the database, the same role as download. - Asynchronous: a restore takes minutes, so the panel answers
202withstatus: "running"at once.- The panel, CLI and SDK poll
GET /v1/databases/:id/drills/:drillId(databases.drill(id, drillId)in the SDK) until the verdict lands.--no-waitreturns right after the start. - One verification runs at a time per panel; another one gets 409
restore_verification_busy.
- The panel, CLI and SDK poll
- Node databases: their backups live on the panel too. If the engine image is not on the panel host yet, the panel pulls it first.
- Verdict:
- Volume restores first check that the archive can be listed, then extract the whole archive into a hidden staging directory inside the volume and swap it into place with same-filesystem renames. Corrupt archives and extraction failures (including a full disk) abort before any existing data is touched; the transient staging copy means the volume needs space for both the old and the restored contents during a restore.
- Database operations use separate staging files. Failed decryption removes partial plaintext instead of retaining an unauthenticated dump on disk.
- Backup and restore operations hold a cross-process lock file (under
op-locks/in the data directory), so an overlapping panel process — a systemd restart overlap or a second instance on the same data directory — cannot interleave a backup with a restore on the same database or volume; a busy lock answers 409, and a lock abandoned by a crashed process is reclaimed after its heartbeat goes stale.
📥 6. Dump import (0.14)
Import an existing dump into a managed database: Database → Backups → Import, ninedeploy databases import <id> --file <dump> (chunks, resumes with --resume <import-id>, and waits for the result), ninedeploy databases imports <id> [--watch], the SDK's databases.importFile(), or POST /v1/databases/:id/imports. It needs admin on the database, the same floor as restoring a backup.
| Route | Purpose |
|---|---|
POST /v1/databases/:id/imports | {source:'upload', sizeBytes, sha256?, filename?, options} → 201 with the advertised chunkSize; or {source:'s3', destinationId, key, options} → 202 (operators) |
PUT /v1/databases/:id/imports/:importId/chunks/:index | One chunk, application/octet-stream |
POST /v1/databases/:id/imports/:importId/start | Check size, sha256 and format, then run → 202 |
GET /v1/databases/:id/imports[/:importId] | History (newest 50) or one import, for polling |
DELETE /v1/databases/:id/imports/:importId | Cancel an uploading or pending import |
An import moves through uploading → pending (every byte is staged) → running → completed, completed_with_warnings or failed. cancelled and expired end an import that never started.
- Uploads come in 8 MiB chunks (
PUT …/imports/:importId/chunks/:index,application/octet-stream). A single multi-GB request would hit Traefik's 60-second read timeout. Chunks arrive in order, and re-sending the last one is harmless.GET …/imports/:importIdreports progress, so an interrupted upload can resume. Only the user who created an import may upload to it or start it. - Limits:
NINEDEPLOY_IMPORT_MAX_BYTES(default 10 GiB). The panel needs twice the dump size plus 512 MiB free under<data dir>/backups/imports/. The staging file is server-named, mode 0600, and deleted when the import completes, fails, is cancelled or expires (24 hours idle). - From a backup destination (
{source:'s3', destinationId, key}): instance operators only. The key must sit under the destination prefix.GET /v1/backup-destinations/:id/objects?prefix=lists candidates. The panel checks the object's size with aHEADrequest, answers 202, and downloads it into staging in the background (uploading→pending). Thenstartit like an upload. - Formats, detected from the file's first bytes (gzip is unwrapped):
| Engine | Accepted |
|---|---|
| postgres | pg_dump -Fc (restored with pg_restore --no-owner --no-acl), or plain SQL (psql -v ON_ERROR_STOP=1). Tar and directory formats are refused. |
| mysql / mariadb | Plain SQL, fed to the client with its sandbox flag (--system-command=OFF / --sandbox). |
| mongo | A mongodump --archive file. admin.*, config.* and local.* are excluded. |
| redis / valkey / keydb | An RDB file, checked first with redis-check-rdb / valkey-check-rdb / keydb-check-rdb from the database's own image. Requires options.confirmReplace: true. |
| dragonfly | An RDB file, checked with redis-check-rdb from the Dragonfly image. Requires options.confirmReplace: true. Dragonfly must be able to load that RDB version; if it cannot, the import ends completed_with_warnings and the pre-import backup is the way back. |
| clickhouse, meilisearch, rabbitmq | Refused. |
- Options (
clean,singleTransaction(postgres; on by default),drop(mongo),confirmReplace,skipSafetyBackup): a key that does not apply to the engine is refused. - Safety backup first:
POST …/start(answers 202) takes a normal database backup labelledpre-importbefore anything is imported. Skipping it is allowed only for an operator, or for a database created in the last 10 minutes. - After the import the panel signs in with the credentials it holds. If that fails, the import ends as
completed_with_warnings: the dump changed those credentials, and thepre-importbackup is the way back. - Restarts: an import running when the panel stops is marked
failed("interrupted by panel restart") at the next boot. Finished import records are kept for 90 days. - Audit:
database.import.create,.upload(the last chunk landed),.start,.safety_backup,.complete,.failand.cancel, with the size, format, source and S3 key, never the contents.
What the content checks are for. The import runs with the database's own superuser or root account, inside the tenant's own container. That account can already reach a shell with SQL alone (for example COPY … TO PROGRAM), and a database admin already receives the same password from GET /v1/databases/:id/credentials. The privilege boundary is therefore the admin floor on the route. The checks below are defence in depth: they block client-side shell escapes and accidental damage to system schemas.
- psql (operators too): a plain SQL dump may contain only the meta-commands pg_dump writes (
\connect,\restrict/\unrestrict,\.,\set ON_ERROR_STOP on). The file is lexed twice, with and without backslash escapes in string literals, and refused if the two readings disagree. Otherwise astandard_conforming_stringschange could hide a meta-command. - mysql / mariadb (non-operators): the dump may not name the
mysql,sys,performance_schemaorinformation_schemaschemas, may not use client commands (\!,source,connect,system,USEof another database, …), and may not switchsql_modetoANSI_QUOTES/NO_BACKSLASH_ESCAPES. A client without a sandbox flag accepts imports from operators only. If a dump's views, triggers or routines carry aDEFINERthe server refuses, re-dump with--skip-definer(mysqldump 8.0.21+) or ask an operator to import it. - Encrypted NineDeploy backups (
NDBK1:/v<n>:files): operators only, since the master key decrypts them. Anyone else should download the backup (it is served decrypted) and import that. - Rollback to 0.13 leaves staging files in
<data dir>/backups/imports/. Delete them by hand (see ROLLBACK.md).pre-importbackups stay restorable.
🌍 7. Public access (0.14)
A managed postgres, mysql, mariadb, redis, valkey, keydb, dragonfly or mongo database can be reached from outside the host on a port of its own, behind a required IP allow-list and with optional TLS termination (Database → Settings → Public access, ninedeploy databases public-access, GET/PUT/DELETE /v1/databases/:id/public-access). Reading the settings needs admin on the database; turning access on, changing it or turning it off is operator-only. GET /v1/databases/:id/credentials then also returns publicConnectionString, and the database list shows publicAccess: {enabled, port}.
Public access exposes the database's root (superuser) account: create a limited user inside the database before you hand out an endpoint. The mechanism, the allow-list and port rules, the TLS modes and the rollback cleanup are described in TRAEFIK_INGRESS.md §9.
Tunnels through the panel (G5.8)
You can reach a database, on the panel host or on a node, from your machine without public access:
ninedeploy tunnel db <db-id> # listens on 127.0.0.1, on the engine's port when it is free
ninedeploy tunnel db <db-id> --port 15432 # a port of your choice (0 picks a free one)Then point psql, a GUI client or a local app at the address it prints, using the database's own credentials. The database port stays closed to the internet.
How it works
- Each local connection opens its own WebSocket to
GET /v1/databases/:id/tunnel. - The panel carries that connection byte for byte to the database container.
- For a database on a node, the node's agent (0.18.7 or newer, capability
tunnel.tcp) opens the connection from inside the database container's network namespace. The panel and the agent talk over a single-use channel encrypted per tunnel. The agent connects only to a running container the panel started as a database. The node owner can turn tunnels off withNINEDEPLOY_AGENT_TUNNELS=off.
Who may use it, and what is recorded
- It needs
adminon the database, the same as revealing its credentials. A scope-restricted API token must also be allowed to write databases. - The database's own login still applies on top.
- Access is re-checked every minute, so a revoked seat, grant or token closes open tunnels.
- An idle tunnel closes after 30 minutes. One user can hold at most 32 open tunnels.
- Each tunnel is audited as
database.tunnel.openanddatabase.tunnel.close, with its duration and byte counts.
Limits for now
--bindlistens on another local address. Anyone who can reach that address can then use the tunnel.
PgBouncer connection pooling
A PostgreSQL database on the panel host can get a PgBouncer sidecar that pools client connections, which helps apps that open many short connections. Turn it on under Database → Settings → PgBouncer connection pooling (web UI since G1.5), with ninedeploy databases pgbouncer <id> enable|disable|status, or with GET /v1/databases/:id/pgbouncer and POST …/pgbouncer/enable|disable. The listen port defaults to 6432 and can be set when enabling. The card shows the pooled connection URL to point apps at. Reading the status needs member on the database, and the full password in the URL needs admin; enabling and disabling start or remove a container on the host, so they are operator-only. Databases on nodes have no PgBouncer yet (422 remote_database).
🛰️ 8. Databases on nodes (0.15.3)
A managed database can run on a remote node instead of the panel host. Choose the node when you create it (Databases → New → host, POST /v1/databases {…, serverId}, ninedeploy databases create --server <id>). The node is fixed for the database's life. Without serverId nothing changes: every existing database stays on the panel host.
- Who and where: placing a database on a node is operator-only (
403 node_placement_operator_only). The node must be online (409 server_not_online) and run agent v0.15.3 or newer withdb.manage(422 node_agent_outdatedotherwise, before anything is written;403 node_feature_disabledwhen its owner setNINEDEPLOY_AGENT_DATABASES=off). A database on a node never adopts an existing volume:existingVolumeis refused, and an existingnd-db-<slug>-dataon the node answers409 node_volume_exists. - On the node it runs as
nd-db-<slug>with the volumend-db-<slug>-data, on its own networknd-dbnet-<slug>, not on the node's sharedninedeploynetwork. A service on the same node that attaches it is connected to that network at its next deploy, so the injectedDATABASE_URL(or the engine's variable) resolves there. Detaching disconnects it. - Responses gain
serverId,serverNameandreachable(nullfor panel-host databases);containerNameandvolumeNamekeep naming the container and volume.GET /v1/serverscounts each node's databases. - Status: every 60 seconds the panel asks each node for its databases' state. A node that does not answer never changes a database's status; the database reports
reachable: falseinstead. - Backups: manual and scheduled backups, policies, off-site upload, restore, drills and dump imports work as for panel-host databases. The dump streams from the node over the agent's sealed stream channel into the panel's backups directory, in the same format and encrypted at rest; the backup records the node. A scheduled backup of a database whose node does not answer is recorded as failed; nothing falls back to the panel host.
- Terminal (published 0.15.3–0.17.1): a shell in the database container opens through the node's agent. Client mode answers
422 client_mode_unsupported; open a shell and run the client there. The 0.18.2 client-terminal implementation is described in Node operations. - Refused: attaching it to a service on another host, the panel host included (
409 attachment_host_mismatch), fan-out targets of a service that uses it (409 fanout_database_host), and moving it to another host. Public access (TLS end to end only) works with agent 0.18.11 or newer, PgBouncer with 0.18.12 or newer (see NODE_OPERATIONS.md). To move one, back it up, create a database on the other host, and restore there. - The node cannot be deleted while it hosts databases, even with
?force=true(409 server_hosts_databases). - Rolling back to a release before 0.15.3: the database keeps running on its node, but the older panel refuses to start, back up or restore it. See ROLLBACK.md, "0.15.x multi-node rollback runbook" before you roll back.
Panel-host attachments (0.15.3): a panel-host database attached to a service (the attach route, a .ninedeploy manifest or a migration bundle) is now connected to the service's own network at the service's next deploy, so its nd-db-<slug> name resolves from the app. Before, only template databases were connected.
See MULTI_NODE.md for nodes, agent versions and the other node features.
🧵 9. KeyDB and Dragonfly (0.15.6)
Two more Redis-protocol engines. Create them like Redis (POST /v1/databases {name, engine: "keydb" | "dragonfly", version?}, ninedeploy databases create, Databases → New). Everything else about a Redis database holds for them: a generated password (shown under Credentials, encrypted at rest), a redis://:<password>@<host>:6379 URI (every Redis client accepts it; there is no keydb://), the REDIS_URL alias when attached to a service, backups, scheduled backups and policies, drills, restore, dump import, public access (with TLS termination: rediss://), Web Studio (Redis Commander) and databases on nodes. No migration is involved: an existing install keeps every database exactly as it was.
| KeyDB | Dragonfly | |
|---|---|---|
| Image (default) | eqalpha/keydb:x86_64_v6.3.4 (arm64_v6.3.4 on an arm64 panel host) | ghcr.io/dragonflydb/dragonfly:v1.34.2 |
| Port, volume | 6379, /data | 6379, /data |
| Start | --requirepass <pw> --dir /data (KeyDB's own thread count) | --requirepass <pw> --logtostderr --dir=/data --dbfilename=dump --df_snapshot_format=false --snapshot_cron=*/15 * * * * |
| Interactive client | keydb-cli (Client button, mode: "client") | redis-cli, which the Dragonfly image ships (Client button, mode: "client") |
| In-container commands | docker exec <db> keydb-cli … | docker exec <db> redis-cli … (as for Redis) |
| Backup | SAVE, then a copy of /data/dump.rdb | SAVE RDB, then a copy of /data/dump.rdb |
| Drill | keydb-check-rdb in the KeyDB image (unverifiable if the image lacks it) | redis-check-rdb in the Dragonfly image (unverifiable if the image lacks it) |
- Versions. KeyDB publishes architecture-specific tags only; the default follows the panel host's CPU. For a node of the other architecture, or any other release, set
version(for examplearm64_v6.3.4). Dragonfly takes its release tag with thev(v1.34.2). Neither default islatest. - Backup and restore are one file. Both engines persist as
/data/dump.rdb: a backup isSAVEplus a copy of it; a restore stops the container, copies the backup over it and starts the container again (a graceful stop would otherwise write the old dataset over the restored file). Dragonfly is started with--df_snapshot_format=false --dbfilename=dumpso that its snapshot is an RDB file with that name instead of its own timestamped.dfsset. ASAVEthat answers an error fails the backup instead of copying a stale file. Dragonfly pads its dump with zeros to a multiple of 4096 bytes (a one-key dump is exactly 4096 bytes); that is a valid RDB file, whichredis-check-rdbaccepts and which loads normally, so the drill never judges the file's tail itself. A Dragonfly backup therefore restores only into Dragonfly (a backup belongs to its database), and an RDB written by Redis loads into Dragonfly only up to the RDB version it understands. - Dragonfly and the kernel. Dragonfly asks for an unlimited locked-memory limit (
ulimit -l) for its io_uring ring. NineDeploy starts the container with Docker's default limits; a kernel or seccomp profile without io_uring makes Dragonfly log a warning and use epoll, which is fine for a managed instance. If your host logs an error instead, raise the memlock limit for Docker (default-ulimitsindaemon.json). - Periodic snapshots. Redis saves on its own schedule; Dragonfly does not unless asked, so it runs with
--snapshot_cron(every 15 minutes) and snapshots again on a graceful stop. A crash loses at most the last quarter hour, as with Redis' default save points. - On a node the panel starts the container with the same arguments and pulls the same image. The node's agent must be v0.15.6 or newer: an older agent does not know the engine names, so creating a KeyDB or Dragonfly database on it answers
422 node_agent_outdatedbefore anything is created. Redis and Valkey on a node are unaffected by the agent's version. - Rolling back to a release before 0.15.6 while a KeyDB or Dragonfly database exists: the older panel does not know the engine. The container keeps running, but while a running row of an engine the older panel does not know exists, the Databases list answers HTTP 500 for instance operators (members still see their databases), scheduled backups of it are recorded as failed, and it can be neither started nor backed up. Delete the row (or its data) before rolling back, or roll forward again. See ROLLBACK.md.
0.18.2 implements sealed node Web Studio for the supported SQL/KV engines; see node Studio operations. Its full acceptance is tracked separately from published 0.17.1.
📦 10. ClickHouse, Meilisearch and RabbitMQ backups (G1.8)
These three engines used to answer "backup not supported". Manual backups, scheduled backups and policies, off-site copies, download, restore and the Check drill now work for them on the panel host and on nodes. On a node the agent runs the same routines against its local Docker, with a temporary file on the node, and streams the result to the panel through the sealed channel, where it is stored encrypted like any backup. This needs an agent that advertises db.dump.extra (0.18.7 or newer); an older one gets 422 node_agent_outdated before anything runs. For a Meilisearch restore the agent reads the image and the data volume from the database container itself. Imports (section 8) remain refused for these engines.
| ClickHouse | Meilisearch | RabbitMQ | |
|---|---|---|---|
| What is backed up | Every user database (all but system and the information schemas), with data, through BACKUP DATABASE … TO File(…) | The whole instance as a Meilisearch dump (POST /dumps): indexes, documents, settings, API keys | The definitions only (rabbitmqctl export_definitions): users, virtual hosts, permissions, queues, exchanges, bindings, policies and parameters. Not the messages in the queues. |
| File | The backup zip | The .dump file (gzipped tar) | JSON |
| Restore | Each database is restored under a temporary name first. Only when all of them succeeded is each live database renamed aside and its copy renamed into place; the set-aside originals are dropped after every swap succeeded. A failure while restoring leaves the current data untouched; a failure while swapping renames that database's original back, and a database already swapped keeps its previous data as <name>__nd_old. Databases not in the backup are kept. | The database is stopped. A one-off container of the same image imports the dump into a new path on the same volume; only after it is healthy are the paths swapped and the old data removed. A failed import keeps the current data. The database is started again either way. | rabbitmqctl import_definitions, then the restore waits until every vhost, queue, exchange and binding in the file exists. The import adds and updates; objects created after the backup are not deleted. |
| Downtime | None | For the length of the import | None |
| Drill (Check) | unzip -l in the ClickHouse image | metadata.json read with tar in the Meilisearch image | The JSON parses and names a RabbitMQ version |
ClickHouse database names must consist of letters, digits and _; a backup or restore refuses others instead of quoting them. Large ClickHouse and Meilisearch operations may run for hours; the limit is six hours per step.
ClickHouse restore refuses to overwrite an existing <name>__nd_restore or <name>__nd_old database. A failed or interrupted restore can leave recovery databases behind; inspect their contents and resolve them manually before retrying. A failed promotion may require restoring the original name manually, and a partially completed multi-database restore is not an atomic transaction.
⏱️ 11. Point-in-time recovery (PostgreSQL, R3)
A dump restores the database as it was when the dump was taken. Point-in-time recovery restores it as it was at any second inside its window: just before a bad migration ran, or before a table was dropped. It is off by default; an upgrade changes nothing until you turn it on.
Turning it on. In the database's Backups tab, Point-in-time recovery → Enable. The CLI is ninedeploy databases pitr enable <dbId> [--retention <days>], and the API is PUT /v1/databases/:id/pitr with { "enabled": true, "retentionDays": 7 }. It needs admin on the database, and the database must be running.
- The database restarts once, now with WAL archiving on.
- Every finished WAL segment (PostgreSQL's change log) is gzip-compressed into a second volume,
<data volume>-wal, on the database's host. - With healthy archiving,
archive_timeout = 60 srequests a WAL switch about once a minute while data changes. A slow or failed archiver can leave a longer backlog; inspect archiving health and the latest recoverable point. This is not a remote-checkpoint RPO guarantee. - The first base backup (
pg_basebackup) is taken right away. After that the panel takes one a day, and you can take one at any time with Take base backup (ninedeploy databases pitr base-backup <dbId>).
Retention. Base backups older than the retention (1–35 days, default 7) are deleted, together with the WAL only they need. The newest base backup is always kept. The window therefore reaches back about the retention, and forward to the newest archived segment. A gap in the archive splits the window.
Status. The card, ninedeploy databases pitr status <dbId> and GET /v1/databases/:id/pitr show:
- the recoverable window, the base backups and the archive size;
- whether archiving works: a failure newer than the last success is shown as failing, also lands on
lastErrorand in the audit log, and the scheduler skips base backups until archiving works again.
Recovering. Recover to a point in time… in the card. The CLI is ninedeploy databases pitr recover <dbId> --name <new database> [--to 2026-11-05T09:30:00Z], and the API is POST /v1/databases/:id/pitr/recover with { "name": "…", "targetTime": "…" }. Without a time, the database is recovered to the latest archived point. The recovery needs admin on the database.
- The database itself is never touched. The recovery creates a new database in the same project, with its own credentials. You point your app at it, or copy what you need out of it.
- A base backup that finished before the target is restored into the new database's volume. The archived WAL is replayed up to the target in a networkless helper container. Only then is the new database started normally.
- It answers at once (202). The card polls the recovery, and the CLI waits for it, unless you pass
--no-wait.GET /v1/databases/:id/pitr/recoverieskeeps the history: the target, what PostgreSQL replayed to (the commit time of the first transaction not applied, or the end of the archive), the base backup it started from and the replay time. - One recovery runs at a time on a panel.
What is refused, and why. A refused recovery keeps no new database behind; the reason is on the recovery row.
- A time with nothing archived after it. PostgreSQL stops a time recovery at the first transaction after the target, so it needs that transaction archived. "Nothing after … has been archived yet": recover to the latest archived point, or try again a minute later.
- A time before the oldest base backup finished. The answer names the earliest recoverable point.
- A missing or damaged segment. Every segment the replay needs is checked (
gzip -t) before anything is created. A recovery to the latest point also checks that the replay really ended in the newest archived segment, because PostgreSQL itself would otherwise stop early at a gap without any error. A time before the damage can still be recovered.
Limits.
- PostgreSQL on the panel host or a supported node. Node archiving/export requires a sealed agent advertising
db.pitr.archive; managed replay from a node archive remains unavailable and uses the offline remote recovery tool. Preview copies answer 422pitr_unavailable. The cluster must use the default 16 MB WAL segments and must not run withwal_level = minimal; enabling checks both. - The live archive lives on the database's host (panel or node), next to the database. Local PITR alone does not protect against losing the host. Operators can opt into encrypted remote checkpoints, which copy a complete base/WAL recovery set to HTTPS S3 storage and recover without the original master key. Full-checkpoint mode uses its configured interval; continuous mode sends closed segments every minute and retains complete remote generations for 1–35 days. Local pruning is held until the newest base is remotely protected, so monitor local disk and archive lag during outages. Additional tablespaces remain unsupported. See the remote archive guide for node capability and transfer requirements. Keep off-site dumps (section 3) as part of the backup policy.
- Disabling deletes the archive and the base backups (the database restarts without archiving). The database remembers since when: its card,
ninedeploy databases pitr statusand, after an hour, the Doctor say that point-in-time recovery is off after having been on, until it is turned on again. Deleting the database keeps the archive volume, like the data volume, until you remove it in Volumes. Enabling again later refuses to reuse such a left-over archive (409pitr_archive_exists). - Restoring the data volume or the archive volume of a database with PITR on is refused (409
pitr_volume_restore_refused). An older data directory under a live archive would write segment names the archive already holds with other contents. Disable PITR first, or recover to a point in time instead. A dump restore (pg_restoreinto the running database) is fine: it is just more WAL. - Rolling back the panel to a version without PITR keeps the database archiving, because the container keeps its flags until it is recreated. Nothing prunes the archive in that version. Disable PITR before rolling back.
⬆️ 12. Major version upgrades (PostgreSQL, MySQL, MariaDB; O2)
A PostgreSQL, MySQL, MariaDB or MongoDB database can move to a newer release (for example PostgreSQL 16 → 18, MySQL 8.0 → 9.7, MariaDB 10.11 → 11.8, MongoDB 6.0 → 8.0) from Settings → Major version upgrade, on the panel host or on a node (On a node). The CLI is ninedeploy databases upgrade start <dbId> --to 18 (or --to 8.4), and the API is POST /v1/databases/:id/upgrades with { "toVersion": "18" } ({ "toMajor": 18 } still works for PostgreSQL). The options route lists the targets in versions.
PostgreSQL moves by dump and restore (below). MySQL and MariaDB move by copy: see MySQL and MariaDB. MongoDB moves by copy too, one release at a time: see MongoDB. Starting, rolling back and finalizing need admin on the database. Reading the options (GET /v1/databases/:id/upgrades/options) and the history needs viewer.
What happens, in order.
- Checks against the running database, before anything stops. The panel reads the real major from the cluster (
server_version_num), not from the configured tag. It refuses, naming what to change, when:- the cluster holds another database;
- there is a role besides the database user;
- the built-in
postgresdatabase holds tables; - there is not room on disk for about twice the database size. The upgrade carries one database and its user, so any of these would be lost silently.
- The new image is pulled while the database still runs.
- The database stops, and the outage starts here. It is dumped through a container that runs its own image on its own volume with no network, so nothing writes after the dump. The dump is kept in the database's backups (the upgrade record names it as
safetyBackupId); the schedule never prunes it. - The dump is restored into a new volume (
nd-db-<slug>-data-u<id>) by the new major, in a second container with no network. The copy is then compared with the original:- the exact row count of every table;
- every sequence;
- the number of indexes, constraints, views, triggers and functions;
- the extensions. The restore stops at the first error. Any difference fails the upgrade.
- Only then does the database switch. The row's version and volume change, and the container starts under the same name. Attached services, PgBouncer and Studio keep their hostname and password. The database joins its services' bridges again.
The CLI waits for the result (--no-wait returns at once). The card shows the phase while it runs. On a test panel, a 500-row database took 11 seconds; the outage grows with the size of the database, because steps 3–4 copy all of it.
Which major the database goes back to. The panel records the major the cluster really runs, read from the server. A database created without a version follows the engine default, which may since have moved past its data; a failure, a rollback or a restart in the middle puts it back on its real major and pins that version.
When it fails. A failure before the switch removes the new volume and starts the database as it was, on its old major. A new major that does not start after the switch is pointed back the same way, and its volume is kept: it was on the network and may hold writes. The reason is on the upgrade row (GET /v1/databases/:id/upgrades). If the panel restarts in the middle, it finishes on boot: before the switch it starts the old database; after it, it starts the verified copy. One host that does not answer at boot is the exception: the upgrade then stays open and is finished by a sweep once the host answers (On a node).
Rollback and finalize. After a completed upgrade the previous volume is kept.
- Roll back (
ninedeploy databases upgrade rollback <dbId> <upgradeId>) points the database back at it, on the old major. Writes made since the upgrade stay on the upgraded volume and are not carried back. - Finalize (
… finalize <dbId> <upgradeId>) deletes the volume the database no longer uses: the previous one after an upgrade, the upgraded one after a rollback. There is no rollback after it. - A second upgrade waits until the first is finalized.
Point-in-time recovery and the upgrade. A PostgreSQL database with PITR on has to have it turned off first, and turning it off deletes the WAL archive and the base backups. That opens a gap: from that moment until PITR is on again and its first base backup has finished, the database has no point-in-time recovery, only its dumps, including the pre-upgrade dump the upgrade keeps (step 3). No moment before the upgrade can be recovered to afterwards. The upgrade card says so when it refuses; after that the database's PITR card, ninedeploy databases pitr status and, after an hour, the Doctor keep saying that PITR is off and since when, until it is turned on again.
While an upgrade runs, the database's stop, start, restart, limits, delete and PITR switch answer 409, and the Doctor will not start it. Backups and restores wait for it.
MySQL and MariaDB
A dump of every database carries the mysql system schema, and loading that into another series is the path both projects advise against. So these two move by copy, with an in-place upgrade on the copy:
- Checks against the running server. The panel reads the real series (
SELECT VERSION()). MySQL 8.4 disablesmysql_native_passwordand 9.0 removed it, so an upgrade to 8.4 or later is refused while any account still uses it; the refusal names the accounts. Move them first withALTER USER … IDENTIFIED WITH caching_sha2_password BY '…'. There must be room for about twice the data directory where Docker keeps volumes (the copy and the safety dump), and for the dump in the backups directory. - The new images are pulled while the database still runs.
- The database stops. A networkless container of its own image (the fence) recovers whatever the stop left, gives the fingerprint and the safety dump, then shuts down slowly (
innodb_fast_shutdown = 0) and must exit cleanly. If it does not, nothing is copied and the database starts as it was. - The data directory is copied into the new volume, read-only from the old one. The old volume is never written to: neither server can downgrade a data directory, so this copy is what makes the rollback possible.
- The new release starts on the copy and upgrades it in place (MySQL upgrades its data dictionary and system tables on start; MariaDB runs
mariadb-upgradethrough the image'sMARIADB_AUTO_UPGRADE). MySQL never skips an LTS series, so 8.0 → 9.7 starts 8.4 on the copy first, shuts it down slowly, then starts 9.7. - The copy is compared with the original: the exact row count of every table (
COUNT(*), not the estimate), the number of indexes, constraints, views, triggers, routines, events and databases, and every account (user@host; the new image may add its own). Then the switch, the start under the same name and the bridges, as for PostgreSQL. Root logs in over TCP with the stored password before the upgrade counts as done.
Users, grants and every database in the server come along. Rollback and finalize work as above.
On a node
The upgrade of a database that lives on a node is the same upgrade: the same steps, the same comparison, the same switch, rollback and finalize, and the same record on the panel. What differs is who touches Docker. The panel keeps the journal and asks the node's agent for each step (db.upgrade): a helper started with no network, a statement, a copy, a slow stop, a removal. Services reach a node database through its own bridge by container name, and the container keeps its name, so nothing has to rejoin.
- The agent must be able to. It has to be 0.21.0 or newer, reached over the sealed transport, and its owner must not have switched databases off (
NINEDEPLOY_AGENT_DATABASES=off). An older agent, an unsealed transport or a node that does not answer is refused before anything stops; the card says which. - No SQL crosses to the node. The panel asks for a statement by its name (
mysql.serverVersion,postgres.fingerprint.rows, …) from a catalogue both share; the agent builds the text. The same catalogue gives the panel host its text, so both run the same words. For MongoDB the statement is an expression in mongosh, and the password reaches mongosh on a file descriptor: never in an argument, never in a file. - Everything is bound to the one database. A volume or a container that does not carry the database's id (
ninedeploy.database.id) is refused before anything runs, and a helper container (nd-db-upg-<slug>-old,-new,-copy) is removed only when it carries the same id. - The safety dump lands on the panel host. It travels over the sealed stream channel into the panel's backups directory, as a backup does, so the panel host needs room for it. The node needs room for the copy, where Docker keeps its volumes.
- A copy runs for as long as it takes. It is started detached and watched, so a lost request does not stop it; a slow shutdown is waited for up to an hour, as on the panel host.
- When the node goes away. The upgrade fails and the row is pointed back on the panel; the node is asked to start the database again, and if it does not answer the reason says so and the database can be started from its page once the node is back. That start first removes whatever the upgrade left on the node, so no leftover helper shares the volume with the server.
- When the panel restarts and the node does not answer. The upgrade stays open with a note, which keeps stop, start, restart, limits, delete and the PITR switch answering 409: nothing may run beside a helper the panel could not remove. The node sweep finishes the recovery within a minute of the node answering.
MongoDB
A MongoDB data directory has a release of its own, the feature compatibility version, which can be behind the server's release: a server starts on data of its own release and of the one before, never on data that is older, and no older server starts once the data is told a newer release. So MongoDB moves one release at a time, and the upgrade does it on the copy only:
- Checks against the running server. The panel reads the server's release (
db.version()) and the data's release, and room for the copy where Docker keeps volumes and for the dump in the backups directory. - The target images are pulled while the database still runs.
- The database stops. A container of its own image on its own volume, with no network (the fence), gives the fingerprint (every collection of every database with its exact count and its indexes, and every account) and the safety dump (
mongodump), then is stopped and must exit cleanly. - The data directory is copied into the new volume, read-only from the old one.
- Each release starts on the copy in turn, and the copy is then told it runs that release (
setFeatureCompatibilityVersion, with the confirmation the server asks for). 6.0 → 8.0 starts 7.0 on the copy, sets 7.0, stops it cleanly, then starts 8.0 and sets 8.0. When the data was already a release behind the server (a server updated without the data being told), the copy starts on the server's own release first. - The copy is compared with the original: every collection's exact count, the number of indexes and views, and every account. Then the switch, the start under the same name, as for the others.
The upgrade record's verification says which release the data ran before and runs now (featureCompatibility). Users and their roles live in the data directory and come along. Rollback and finalize work as above: the old volume was never written to, so its data still runs the old release for the old server.
Targets. 7.0 and 8.0 (the engine default), from 6.0 or later. 5.0 and older: upgrade by hand to 6.0 first.
Targets. MySQL 8.4 (LTS) and 9.7 (the engine default), from 8.0 or later. MariaDB 10.11, 11.4, 11.8 and 12.3, from 10.6 or later, directly.
Limits.
- On the panel host and on nodes. PostgreSQL goes to 14–18. On a node the agent has to be 0.21.0 or newer and sealed (On a node). pgvector databases and preview copies are refused. The other engines (the Redis family, ClickHouse, Meilisearch, RabbitMQ) have no major upgrade.
- MySQL 5.7 and MariaDB before 10.6 are refused: upgrade them by hand to 8.0 or 10.6 first.
- PITR must be off (its archive and base backups belong to one cluster). Turn it off, upgrade, turn it on again. A rollback is refused while PITR is on.
- Deleting the database keeps both volumes, like any data volume. A new database created later with the same name would pick up the old
nd-db-<slug>-datavolume. If that volume holds another major's data, the create is refused with the major named, instead of starting a server that cannot read it.
A database without a version
A database created before 0.18.28 without a version, whose volume was created by an older default, is the one row the version pin leaves alone on purpose (section 1): nobody can tell which release its data runs, and its next Start runs the default, as before. For MySQL, MariaDB and MongoDB that upgrades the data in place, with no way back. The panel does not guess for it:
- It is shown. The Doctor names it (
database_version_unknown, a warning) while it is stopped and no container exists. The database page gets a Version card, andninedeploy databases version show <id>prints the same: the image that created the volume, what a Start would run today, and the releases it may be named. - The release is named before the first Start, by an admin of the database: on the card (Set version), with
ninedeploy databases version set <id> <release>, orPUT /v1/databases/:id/version. The list is the engine's known releases, the release of the image that created the volume and today's default. The likeliest answer is the one that created the volume, unless a later default has run on it since: when in doubt, take a backup first. - A name is tried before it counts. The first Start on a named release watches the container for 12 seconds. One the server does not stay up in (an older release refuses to start on newer data) is removed, the database stays stopped, and the start is refused (
database_version_named), with the name still open: name another and start again. One that stays up makes the release the database's version, like any other.
Nothing here touches the data: the version is written to the row, only to one without a version or with a name not run on yet, never while an upgrade runs or a trial is in progress. Each name is audited (database.version_set).
🔄 13. A standby replica and its promotion (PostgreSQL; N12)
A standby is a second copy of the database, beside it on the host it runs on, that replays its WAL archive and streams from the primary. It is built from the newest base backup, so it needs point-in-time recovery on (section 11). Streaming asks one thing of the primary: one line in its pg_hba.conf that admits the standby's connection, which the panel adds before the standby starts. No role and no password of its own: the standby connects as the database's own user, with the password its container already carries for the day it is promoted. A committed change is on the standby within a second. When the primary has recycled WAL the standby had not received, the standby takes it from the archive and streams again. While it replays, it answers read-only queries with the primary's data and roles, and the primary's password opens it. Its container is nd-db-<slug>-standby, its volume nd-db-<slug>-data-sb<id>.
Streaming. The card and ninedeploy databases standby status <id> say how the standby receives: Streaming from the primary, or replaying the WAL archive, about a minute behind (streaming in GET /v1/databases/:id/standby). The archive is never gone: it is what the standby falls back to, and what point-in-time recovery keeps. A standby that was ready before its host could stream (built by 0.21.0, or on a node whose agent was then too old) is started again with streaming once its host can: at the next pass of the panel, at most once in ten minutes.
Building. Database → Backups → Standby replica → Create standby (ninedeploy databases standby create <id>, POST /v1/databases/:id/standby). It can be created armed for the automatic failover (--auto-failover). The panel takes a base backup, extracts it into a new volume labelled as the database's, and starts the standby's container. The build runs in the background; the card and ninedeploy databases standby status <id> follow it. A database has at most one standby, and the copy needs about the size of the data directory free.
Promoting by hand. Promote the standby is a planned handover that loses nothing committed, in this order.
- The primary switches its WAL and is made read-only: everything committed is in the archive from here, and nothing more is committed.
- The standby replays past the switch.
- The primary is stopped cleanly (its shutdown archives the last segment) and removed. Its volume is never written again.
- The standby replays the end of the archive and is promoted (
pg_promote()). - The database's row points at the standby's volume, and that volume starts under the primary's name: every attached service keeps its hostname and password. The database stops for a few seconds. A base backup is taken at once on the new timeline.
Promote without the handover is for a primary that does not answer. The standby becomes the database with what it had received: with streaming, what the primary committed in its last moment may be missing; with the archive alone (a node whose agent is older than 0.21.1), everything not yet archived, which is up to a minute of committed changes. The card says so before you confirm, and the previous volume keeps those changes. A primary that still answers is refused: stop it first, or promote with the handover. Before the standby is promoted it replays what the primary had archived (it polls the archive every five seconds); a standby that does not reach the end of the archive within two minutes is promoted with what it has, and its row says so.
What stays. The volume the database ran on before is kept until Delete the previous volume (ninedeploy databases standby finalize <id>), or until it is brought back as the standby (Bringing it back, next). The button stands beside whichever standby is the newest, so the volume can be deleted while the standby built again is already live. With two promotions not finalized, the newest kept volume goes first. Until one or the other, it must never be started by anything else: started as it is, it comes up as a primary of the old timeline with the changes the standby never saw.
Bringing it back. The volume a promotion left can become the standby again: Bring back as the standby on the card (the database's name is asked for), ninedeploy databases standby rewind <id>, POST /v1/databases/:id/standby/rewind. It is rewound to the database as it is now (pg_rewind, taking what it needs from the database and from the archive) and started as a standby that streams from the primary. No copy of the data directory is made and no room for one is needed: measured at 1.5 seconds for a crashed primary of 62 MB, and no rewind at all for a volume a handover stopped cleanly. What the volume holds that the database never saw is lost: after a promotion without the handover, the changes of the primary's last moment. The read-only switch a handover left on it is dropped, so that the volume can be promoted again later. From then on it is the standby's volume: removing the standby removes it, and there is nothing left for Delete the previous volume (409). A volume that a container still mounts is left alone, and nothing is done to it. It is not started until the rewind has succeeded. A rewind that fails, or is cut by a restart of the panel, keeps the volume as it was kept and the row says so; after one that stopped half-way the volume may be unusable, and deleting it is what is left for it. The status says when it cannot be brought back (rewindRefusal in GET /v1/databases/:id/standby): a standby is live, the database is not running, an upgrade is in progress, or the node's agent is older than 0.21.1. It needs the WAL since the promotion, on the database or in the archive: once the retention has removed it (with the base backups before the one taken after the promotion), the volume cannot come back; the build fails, says so, and keeps the volume, and a standby from a base backup is the way then.
Automatic failover. A standby can be armed: Arm automatic failover on the card (the database's name is asked for), ninedeploy databases standby auto-failover <id> on, PUT /v1/databases/:id/standby with {"autoFailover": true}, or autoFailover when it is created (--auto-failover). Armed, the panel asks the primary every thirty seconds and asks Docker what its container is:
| What the panel sees | What it does |
|---|---|
| The primary answers. | Nothing. The watch starts again. |
It does not answer, and its container is stopped or gone (docker kill, docker stop, docker rm: the restart policy leaves a stopped container so, and never brings back a removed one). | Starts it again, once: a primary that comes back loses nothing. |
It does not answer, and its container is gone, is not running, or has restarted twice or more since it last answered (a server that cannot start again reads running now and then). | Gone. Two minutes after the first such look (by default) the standby is promoted without the handover. |
| It does not answer, and its container runs without having restarted: it may still be recovering after a crash, or hung. | Silent. Ten minutes after the first such look (by default) the standby is promoted without the handover. |
Before the promotion the standby replays the end of the archive. What the primary had not passed on is missing, as in any promotion without the handover. The row, the audit log (database.standby_failover, with what the panel saw) and the Doctor say so, and the card and ninedeploy databases standby status <id> show the wait while it lasts: since when the primary has not answered, what was seen, and when the standby is promoted unless the primary comes back. Disarm automatic failover ends it at any time before.
The waits are yours to set (Change the waits on the card, ninedeploy databases standby waits <id> --gone-after <minutes> --silent-after <minutes> --pause-after <count>, or the same options when the standby is created): how long a primary must be gone (from half a minute to twenty-four hours; two minutes by default), how long one whose container only does not answer is given (never less than the other; ten minutes by default: a large database may take longer than that to recover after a crash), and after how many automatic failovers of the database in a day the standby built again is left unarmed (from one to a hundred; three by default). The standby built again after a failover is given the same waits. A wait changed while a failover is waiting moves its time: one shortened past the time already gone takes effect at the next look.
Nothing asks first: armed, the panel may lose the last moment's committed changes without you (up to a minute with the archive alone). What is never judged: a database whose row does not say running (stopped or failed by hand), a Docker that does not answer, an upgrade in progress, and a standby that does not answer. A restart of the panel starts the two minutes again (RESTART_STATE.md).
After a failover a standby is built again. An armed standby means the database is to keep one. When it takes over, by the automatic failover or by a promotion by hand, a new standby is built at once from the base backup the promotion takes on the new timeline, and armed. After three automatic failovers of one database within twenty-four hours (three by default) the new standby is built and left unarmed: each failover costs what the primary had not passed on, and the third says that the cause is not going away by itself. The Doctor says so; arm it again by hand once the cause is found. A standby that cannot be built (no room for a copy, with the volume the database ran on before still kept beside the new copy) is not retried by itself: its row says why, and the card offers to create one.
Synchronous replication (opt-in, off by default). By default a commit returns as soon as the primary wrote it, and the standby has it within a second: the crash of the primary can lose that last moment. turned on with Turn synchronous replication on on the card, ninedeploy databases standby sync <id> on, PUT /v1/databases/:id/standby with {"synchronous": true}, or synchronous when the standby is created (--synchronous), and while the standby streams the primary's commits wait for it: a commit returns once the standby flushed it, so the crash of the primary loses nothing it acknowledged. It costs about three milliseconds a commit (measured on PostgreSQL 18.7: 2.1 ms asynchronous, 5.3 ms synchronous). The setting is the primary's (synchronous_standby_names, by ALTER SYSTEM, so it survives its restarts), and the panel makes it agree with the standby's row on every pass: a standby that does not stream is not waited for. The panel lifts the setting within one pass (thirty seconds) and sets it again when the standby streams; until then the database writes alone, as without the setting. It is lifted before the standby is removed, before a handover's WAL switch, and after every promotion (a base backup copies the file the primary kept it in; the standby built again after a promotion keeps the setting on its row); a volume brought back by a rewind loses it with the read-only switch. A session that must not wait sets synchronous_commit = local. The costs: a standby that is away costs up to thirty seconds of waiting commits (measured: a commit waits for ever while no standby is connected, and statement_timeout does not cut it) until the panel's next pass lifts the setting; a database that does not answer cannot have its standby removed, nor be deleted, while its row says the database waits (409 standby_sync_primary): start it first. With the automatic failover armed, synchronous replication is what makes a failover lose nothing that was acknowledged: arm both.
Point-in-time recovery goes on. The standby archives while it replays (archive_mode=always), so at the promotion the new timeline's history file reaches the archive at once. The archive stays where the primary wrote it, <volume>-wal; the row names it from then on (pitr_archive_volume). A recovery to a time after the promotion starts from the base backup taken on the new timeline; one to a time before it starts from the older base backup and follows the fork. Retention keeps the base backup a standby was built from, and the WAL after it, while the standby lives. Point-in-time recovery cannot be turned off while a database has a standby: the standby replays that archive.
On a node. A database that lives on a node has its standby beside it, on the same node, from the same card and the same commands. The panel keeps the whole journal and asks the node's agent for what touches its Docker (db.standby, agent 0.21.0 or newer; a node whose agent is older says so on the card, and nothing is built). Streaming needs the node's agent 0.21.1 or newer: it adds the line to the primary's pg_hba.conf and starts the standby with the primary's address; with an agent that can build a standby but is too old to stream (0.21.0), the standby has the archive alone and the card says so, and it streams by itself once the agent is updated. Bringing the previous volume back needs the agent 0.21.1 or newer too: the agent runs the rewind itself, from the catalogue's script, with the database's password in a 0600 env file and never on a command line. The standby's container runs on the database's own bridge nd-dbnet-<slug>, so after a promotion the services attached to the database keep their hostname. The WAL archive is a volume on the node, and a database that was promoted keeps the archive its primary wrote: from then on every archive operation on the node names it (pitr_archive_volume). The node's retention keeps the base backup a live standby still replays from, as the panel host's does. A node that cannot be reached, or whose Docker cannot answer, is never judged by the automatic failover: nothing is known, and nothing is done. Synchronous replication needs the same agent 0.21.1 or newer (its statements are that release's): with an older one the creation and the settings are refused (409 standby_agent_sync) and nothing is written.
The limits of this release. A standby is built where its database runs, on the panel host or on its node: it protects against a damaged volume, a failed change or a lost container, not against the loss of that host. There is no standby on another host than its database; synchronous replication is opt-in and off by default (above), so the standby is a second or less behind, not zero; a standby of a Redis or Valkey database is the next section. The automatic failover watches from the panel host too. A standby that was not armed is not built again after its promotion: create one by hand. Deleting the database removes a standby that was only replaying; the volume of a promoted one is the database's own, and stays like any data volume. If the panel restarts during a build, the half-built standby is removed and marked failed (a volume that was being brought back stays, kept as before); during a promotion, the promotion continues from where it was (RESTART_STATE.md).
🧩 14. A standby of a Redis or Valkey database (N12)
A standby of a Redis or Valkey database is a replica: a second server, beside the database, on the panel host or on its node, that receives every write the database acknowledges, within a second. Nothing is copied for it and no point-in-time recovery is needed: a new volume is made, and a container with the database's own image, command and limits is started on it as the database's replica. It receives the whole dataset from the database (about six seconds for a small one), then follows it. It answers reads with the database's data and password, and refuses writes (READONLY). Its container is nd-db-<slug>-standby, its volume nd-db-<slug>-data-sb<id>. The status says which engine's standby it is (engine in GET /v1/databases/:id/standby).
Building. Database → Backups → Standby replica → Create standby (ninedeploy databases standby create <id>, POST /v1/databases/:id/standby): the same card and the same commands as a PostgreSQL standby (section 13). The build runs in the background and is ready once the replica is linked and has the dataset, two minutes at most. A database has at most one standby, and it must be running. The replica is a second server: its memory comes beside the database's (a dataset held in memory is held twice on the host), and its volume takes room on the disk, where its dataset is saved by the image's own policy.
Promoting by hand. Promote the standby is a planned handover that loses nothing the database acknowledged, in this order.
- The database's writes are held (
CLIENT PAUSE … WRITE): reads are answered, a write waits. - The replica receives the last of the writes: its offset is the database's, and the database's own says the same.
- The database is stopped and its container removed. Its volume is never written again.
- The replica is promoted (
REPLICAOF NO ONE) and its dataset is saved on its volume (BGSAVE). - The database's row points at the replica's volume, and that volume starts under the database's name, with the database's own command: every attached service keeps its hostname and password. The database stops for a few seconds (measured at 3.6 seconds under its name, from the first request it did not answer to the first it did).
A replica that does not receive the last of the writes within two minutes ends the promotion: the writes go again, the replica is ready as before, and its row says why (error). A primary that does not answer is refused: stop the database first, or promote without the handover. Promote without the handover promotes the replica where it stands: what the database had not passed on is missing, and the previous volume keeps it. A database that still answers is refused.
Automatic failover. Armed, a standby of these engines is watched exactly as a PostgreSQL one is (section 13): the panel asks the database every thirty seconds, and asks Docker what its container is. A database that does not answer and whose container was stopped is started again, once. One still gone two minutes after (its container gone, not running, or restarted twice or more since it last answered: measured on the image, a server that cannot start again reads running now and then, so the count says it), or running without answering for ten, hands the database to the replica, where it stands. Nothing is received at the end, for there is nothing to receive. What the database had not passed on is then missing: with the link up, its last moment; with the link down before, everything since. The previous volume keeps it. After the failover a new standby is built, a replica of the database as it is now, and armed with the same waits; after three automatic failovers of the database in a day it is built and left unarmed (the Doctor says so). Arm it on the card (the database's name is asked for), with ninedeploy databases standby auto-failover <id> on, PUT /v1/databases/:id/standby with {"autoFailover": true}, or autoFailover at the creation. Nothing asks first.
Synchronous replication (opt-in, off by default), turned on with Turn synchronous replication on on the card, ninedeploy databases standby sync <id> on, PUT /v1/databases/:id/standby with {"synchronous": true}, or synchronous when the standby is created (--synchronous), as for PostgreSQL (section 13): while the standby is linked, the database refuses a write that no replica would receive (min-replicas-to-write 1): at once with the standby stopped, and after ten seconds with it paused (measured on Redis 8.8.4 and Valkey 9.1.4). A write that is accepted is on its way to the standby, so the crash of the database loses nothing it acknowledged. The setting lives in the database's memory (the server runs without a config file), so a restart of the database forgets it: the panel sets it again within one pass. A standby that is not linked is not waited for: the panel lifts the setting within one pass (thirty seconds) and sets it again when the link is up; until then the database writes alone. It is lifted before the standby is removed; a promotion needs nothing, the promoted volume starting under a new container. The costs: with the link down the database refuses writes for up to thirty seconds, until the panel's next pass lifts the setting; a database that does not answer cannot have its setting changed (409 standby_sync_primary). With the automatic failover armed, synchronous replication is what makes a failover lose nothing that was acknowledged: arm both.
What stays, and bringing it back. As for PostgreSQL: the volume the database ran on before is kept until Delete the previous volume (ninedeploy databases standby finalize <id>), or until it is brought back as the standby (Bring back as the standby, ninedeploy databases standby rewind <id>). Brought back, it is started as the replica again on that same volume: it is given what it missed since the promotion, or the whole dataset when the database no longer holds it. Nothing is extracted and no room is needed. What the volume holds that the database never saw is lost. From then on it is the replica's volume: removing the standby removes it, and there is nothing left to finalize.
With the rest of the panel. A major version upgrade is refused while the database has a standby (standby_exists): remove the standby first, or promote it. Deleting the database removes a standby that was only replicating; the volume of a promoted one is the database's own, and stays like any data volume. A restart of the panel during a build removes the half-built standby and marks it failed (a volume that was being brought back stays, kept as before); during a promotion, the promotion continues from where its row says: from the database's removal on, nothing more is asked of it. Writes held for a handover are let go when the promotion is given up, and end by themselves within ten minutes if the panel dies (RESTART_STATE.md).
The password on the command line. The replica's container carries the database's password twice on its command line (--requirepass, as the database's own container does, and --masterauth): visible to whoever can inspect containers on the panel host, who can read the database's own container the same way.
The limits of this release. The standby is built where its database is, on the panel host or on its node: a node needs its agent 0.21.1 or newer for it, and the card and the CLI say so with an older one. It protects against a damaged volume, a failed change or a lost container, not against the loss of that host. Synchronous replication is opt-in and off by default (above); there is no standby for KeyDB or Dragonfly.
Source guide (installer links and live inventory counts are normalized for this site): docs/DATABASES_BACKUPS.md.