Export — MDDB API
Export and backup operations
Export documents #
POST /v1/export
Export documents in NDJSON or ZIP format with optional metadata filtering.
Selected documents (2.19.7+): keys lists the documents to export,
each {key, lang}; they are exported in the order listed, each once, and
a key that names no document is skipped. With filterMeta as well, only
the listed documents that also match are exported. Without keys the
export is the whole collection (or what filterMeta selects), as before.
An entry without key or lang is refused with 400.
NDJSON: Newline-delimited JSON, one document per line.
ZIP: Archive with markdown files named {key}.{lang}.md.
Authorization: BearerAuth or APIKeyAuth or none
Request body #
Required.
Content type application/json: ExportRequest
{
"collection": "blog",
"filterMeta": {
"status": [
"published"
]
},
"format": "ndjson",
"keys": [
{
"key": "post1",
"lang": "en_GB"
}
]
}
Responses #
| Status | Description | Body |
|---|---|---|
200 |
Export file | string (binary) (application/x-ndjson) |
400 |
Invalid request | ErrorResponse (application/json) |
Create backup #
GET /v1/backup
Copy the database through a read transaction (a consistent state even while writes continue) and check the copy with bbolt's full integrity check before keeping it. A failed check returns 500 and means the live database is damaged; see docs/BACKUP.md. MDDB_BACKUP_VERIFY=false skips the check.
Authorization: BearerAuth or APIKeyAuth or none
Parameters #
| Name | In | Type | Description |
|---|---|---|---|
to (required) |
query | string |
Destination path for backup file |
Responses #
| Status | Description | Body |
|---|---|---|
200 |
Backup created successfully | object (application/json) |
400 |
Invalid request | ErrorResponse (application/json) |
500 |
The backup could not be written, or the copy failed the integrity check (the live database is damaged) | ErrorResponse (application/json) |
Restore from backup #
POST /v1/restore
Restore database from a backup file
Authorization: BearerAuth or APIKeyAuth or none
Request body #
Required.
Content type application/json: object
| Property | Type | Description |
|---|---|---|
from (required) |
string |
Path to backup file |
{
"from": "backup-20250109.db"
}
Responses #
| Status | Description | Body |
|---|---|---|
200 |
Database restored successfully | object (application/json) |
400 |
Invalid request | ErrorResponse (application/json) |
403 |
Read-only mode | ErrorResponse (application/json) |
500 |
Restore failed (unusable backup, copy or reopen error). The previous database is rolled back and keeps serving — the backup is validated before the live file is touched, and a pre-restore snapshot guards the swap. | ErrorResponse (application/json) |
List backup files #
GET /v1/backups
The backup files in the server's backup directory (MDDB_BACKUP_DIR), newest first: regular files ending in .db in the directory itself, never a folder inside it, a symlink, a checksum or temporary file, or the live database. Backups a scheduled rule stores in object storage are not listed. Admin on "*". See docs/BACKUP.md.
Authorization: BearerAuth or APIKeyAuth or none
Parameters #
| Name | In | Type | Description |
|---|---|---|---|
limit |
query | integer |
Rows per page (default 100, at most 1000) Minimum 1. Maximum 1000. |
offset |
query | integer |
Rows to skip (default 0) Minimum 0. |
Responses #
| Status | Description | Body |
|---|---|---|
200 |
One page of the backup files | object (application/json) |
401 |
Not signed in | ErrorResponse (application/json) |
403 |
Not an administrator of "*" | ErrorResponse (application/json) |
500 |
The backup directory could not be read | ErrorResponse (application/json) |
Download a backup file #
GET /v1/backups/{name}/download
One backup file listed by GET /v1/backups, with Content-Length and Content-Disposition attachment; range requests are answered with 206. In the per-collection layout the download is the main file only. Every download, served or refused, is audit-logged as backup.download. Admin on "*".
Authorization: BearerAuth or APIKeyAuth or none
Parameters #
| Name | In | Type | Description |
|---|---|---|---|
name (required) |
path | string |
A single file name from the list; no path separator, "..", absolute path or NUL |
Responses #
| Status | Description | Body |
|---|---|---|
200 |
The backup file | string (binary) (application/octet-stream) |
206 |
The requested range of the backup file | string (binary) (application/octet-stream) |
401 |
Not signed in | ErrorResponse (application/json) |
403 |
Not an administrator of "*" | ErrorResponse (application/json) |
404 |
Not a listed backup (the same answer for every such name) | ErrorResponse (application/json) |