dump_database
Captures an application-consistent logical dump of a Postgres or Redis database before migrations or destructive changes, storing the artifact server-side.
Instructions
Capture a logical, application-consistent dump of a managed database.
The daemon runs the engine's own dump tool — ``pg_dump --format=custom``
for Postgres, ``redis-cli --rdb`` for Redis — from a throwaway container
built from the database's OWN image, against the running server. This is
the dump to take before a migration or a destructive change: unlike the
volume backup (``nerdit backup --volume``, no tool), it is consistent by
the engine's rules rather than by the filesystem's.
CUSTODY: the artifact is a server-side tar under the daemon's backups
directory holding **every row** of ``name``; it is never served over
HTTP and nothing but metadata comes back here — basename, size, sha256,
engine, format, duration. Treat the basename as the handle: it is what
``nerdit db restore`` takes.
RETENTION: the daemon keeps the last ``[retention].dump_keep_last``
dumps per database (default 5) and prunes older ones on its hourly
sweep, so a dump is not an archive. Copy one off the box if it must
outlive that window.
TIMEOUT: the default matches the usual MCP client read budget, not
the route's own 900: if your client gives up first, **a longer dump still completes
server-side and appears in ``list_database_dumps``**. So a read timeout
here is not a failure — call ``list_database_dumps`` and take the newest
entry. Do NOT blind-retry: this tool mints its own idempotency key per
call, so a retry is a second real dump (and the first one may still be
running, which answers ``409 dump.in_progress``).
Authorization is **owner-or-admin plus token scope**: a scoped submitter
can dump the databases it created, which is what makes this usable over
the (submitter-capped) cloud link. Refusals you should branch on: ``409
dump.database_not_ready`` (not running, or still doing initdb — poll
``list_databases`` for ``db_ready``), ``409 dump.in_progress`` (this
database already has one running; distinct from the daemon-wide
``backup.in_progress``), ``409 dump.too_many_in_flight``, ``409
dump.insufficient_disk`` (the error object carries top-level
``required_bytes`` / ``free_bytes``), ``422 dump.not_a_database``, and
``500 dump.failed``
whose ``hint`` is the tool's own last output line. There is deliberately
**no restore tool** — restoring replaces live data and stays on the CLI
(``nerdit db restore``) and REST.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of an existing managed database (``kind=database``); an app or model row is refused. | |
| timeout_s | No | Seconds the dump tool may run server-side; omit for 300. Floored at 1 and otherwise passed straight through, so a value above the daemon's ``[services].dump_timeout_max_s`` gets the authoritative 422 ``dump.timeout_too_large`` instead of being silently clamped. |