Skip to content
OvertCMS Docs

Backups, Export & Migration

Export and import secret-free portable NDJSON site backups from the Admin UI, HTTP API, or CLI—including zero-downtime SQLite-to-PostgreSQL migrations.

Start Here Updated
View as Markdown

OvertCMS makes it easy to back up an entire site, clone content between staging and production, or migrate cleanly from SQLite to PostgreSQL—either directly from the Admin UI, over the Admin HTTP API, or with the overtcms CLI.

Export & Import from the Admin UI or HTTP API#

You do not need SSH access to back up or restore a site. Site administrators (site:manage capability) can export and import directly over HTTP:

  • In the Admin UI: Go to Settings → Backup & Import to download a .ndjson archive, upload a backup for a Dry-Run Validation Preview, and apply the live import (protected by Step-Up MFA when MFA is enrolled).
  • Via Admin HTTP API:
    • Export: GET /admin-api/v1/sites/{siteSlug}/export — Streams a secret-free application/x-ndjson archive (<siteSlug>-export.ndjson).
    • Dry-run validate: POST /admin-api/v1/sites/{siteSlug}/import?dryRun=true — Accepts raw NDJSON or multipart/form-data (file field, up to 64 MiB) and returns { valid, summary } without touching the database.
    • Apply live import: POST /admin-api/v1/sites/{siteSlug}/import?dryRun=false — Validates and applies the archive (requires fresh Step-Up MFA if enrolled).

CLI Subcommands#

Text
Usage:
  overtcms <command> [flags]

Commands:
  serve     Run migrations, bootstrap default site, and start configured HTTP/worker planes
  migrate   Run database migrations and exit
  export    Export a site's schema, media metadata, entries, and redirects as portable NDJSON
  import    Import a portable NDJSON archive into a site (supports --dry-run)
  version   Print version and runtime build information

overtcms serve#

Runs pending database migrations, idempotently bootstraps the default organization and site, and starts all configured HTTP listeners and/or the async Worker plane. Handles SIGINT and SIGTERM for graceful shutdown with a 15-second drain timeout.

Bash
overtcms serve --db-driver=postgres --db-dsn="$OVERTCMS_DB_DSN" --planes=delivery,agent

overtcms migrate#

Applies all database migrations for the configured driver (sqlite or postgres) and exits 0 on success. Useful as a Kubernetes init container or CI/CD pre-deploy release step before rolling out new replicas.

Bash
overtcms migrate --db-driver=postgres --db-dsn="$OVERTCMS_DB_DSN"

overtcms version#

Prints the build version, Go toolchain version, OS, and CPU architecture:

Bash
overtcms version
# overtcms 0.1.0-dev (go1.23.4, linux/amd64)

Portable NDJSON Export & Import#

OvertCMS Core uses a streaming, line-oriented NDJSON archive format (overtcms-ndjson v1) to migrate entire sites cleanly between environments—including cross-engine migrations from SQLite to PostgreSQL (or vice versa).

Zero-Secret Guarantee#

Exports are designed to be safely checked into backup buckets or shared between staging and production environments:

Portable Flags#

Both export and import accept all standard Configuration flags (--db-driver, --db-dsn, etc.) alongside these portable-specific flags:

Flag Commands Default Description
--site export, import OVERTCMS_DEFAULT_SITE_SLUG (default) Target site slug to export from or import into.
--out export stdout (-) Output file path. When writing to a file, logs go to stderr and the JSON ExportSummary prints to stdout.
--in import stdin (-) Input NDJSON file path.
--dry-run import false Validate the entire archive against the target site and print ImportSummary without performing any database writes. Exits non-zero if validation errors are found.

Exporting a Site#

Export to a file (prints ExportSummary JSON to stdout):

Bash
overtcms export \
  --site=default \
  --out=backup-default.ndjson \
  --db-driver=sqlite \
  --db-dsn=./.data/overtcms.db
JSON
{
  "siteSlug": "default",
  "components": 4,
  "postTypes": 3,
  "media": 28,
  "entries": 142,
  "redirects": 7
}

Or stream directly to stdout for piping or compression:

Bash
overtcms export --site=default | gzip > backup-default.ndjson.gz

Exports use keyset cursor pagination internally (never SQL OFFSET), streaming up to 10,000 pages per resource type in deterministic order.

Importing a Site (Dry-Run First)#

Always validate an archive with --dry-run before mutating a target database:

Bash
overtcms import \
  --site=default \
  --in=backup-default.ndjson \
  --dry-run \
  --db-driver=postgres \
  --db-dsn="postgres://overtcms:pass@localhost:5432/overtcms?sslmode=disable"

Once --dry-run exits 0 with no errors, run the actual import:

Bash
overtcms import \
  --site=default \
  --in=backup-default.ndjson \
  --db-driver=postgres \
  --db-dsn="postgres://overtcms:pass@localhost:5432/overtcms?sslmode=disable"
JSON
{
  "dryRun": false,
  "siteSlug": "default",
  "siteUpdated": true,
  "components": 4,
  "postTypes": 3,
  "media": 28,
  "entries": 142,
  "redirects": 7
}

Cross-Engine Migration (SQLite to PostgreSQL)#

You can pipe an export directly from a local SQLite database into a PostgreSQL instance in one command:

Bash
overtcms export --db-driver=sqlite --db-dsn=./.data/overtcms.db \
  | overtcms import --db-driver=postgres --db-dsn="postgres://overtcms:pass@localhost:5432/overtcms?sslmode=disable"

NDJSON Archive Format Specification#

Each line is a JSON envelope {"type": "<recordType>", "data": { ... }} emitted in dependency order:

Order Record type Contents
1 header Format metadata (format: "overtcms-ndjson", formatVersion: 1, cmsVersion, siteSlug, exportedAt).
2 site Secret-free site settings (slug, name, baseUrl, timezone, defaultLocale, locales, instruction, visibility, agentWritesPaused).
3 component Reusable Component definitions sorted lexicographically by slug.
4 post_type PostType schema definitions sorted lexicographically by slug.
5 media MediaAsset metadata records (paginated by cursor).
6 entry Full Entry records (including draftData, publishedData, status, version, locale, and trashed entries).
7 redirect 301 redirect rules (fromPath, toPath, entryId, statusCode).

Pre-Flight Validation & Safety Limits#

Before applying a single write during import, OvertCMS Core parses and validates the entire archive in memory:

  • Hard limits: maximum 64 MiB per NDJSON line (maxImportLineBytes) and 100,000 total records per archive (maxImportRecords).
  • Media safety: validates every storageKey (preventing path traversal), verifies mimeType against the strict allowlist, and automatically remaps SHA-256 deduplicated media asset IDs/URLs inside entries.
  • Schema validity: validates all Components and PostTypes (including nesting depth and cycle checks) against the merged site schema.
  • Entry integrity: checks every entry's locale, slug uniqueness (within the archive and against existing DB rows), singleton cardinality, non-slug unique fields, draftData schema validity, publishedData publish-mode validity, and media reference existence.
  • Fail-before-write: if any validation error is collected, import (including --dry-run) returns the full errors list and makes zero writes.
Documentation

Start here