Export — MDDB API

Export and backup operations

Export documents #

POST /v1/export

Export documents in NDJSON or ZIP format with optional metadata filtering.

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"
}

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)