Postgres dumps

ownstack db dump streams a pg_dump --format=custom of an app's linked Postgres database straight to your machine. Auto-detects MySQL apps too. No temp files on the control plane.

Quick start

$ ownstack db dump --app=<app>
Streaming database dump…
Dump complete: <app>-<stack>-<timestamp>.dump (12345678 bytes)

Options

FlagWhat it does
--app=NAMETarget app. Defaults to the linked app in .ownstack-config.
--stack=IDRequired when the app deploys to multiple stacks; otherwise auto-picks.
--output=FILEOutput path. Defaults to the server's suggested filename: <app>-<stack>-<UTC-timestamp>.dump (Postgres) or .sql (MySQL).

What's in the file

The dump is Postgres custom format — binary, compressed, restorable with pg_restore. It includes schema, data, indexes, sequences, triggers, and grants. pg_dump --format=custom on the source.

Verify it's a valid dump:

$ file my-app.dump
my-app.dump: PostgreSQL custom database dump - v1.16-0

$ pg_restore --list my-app.dump | head
; Archive created at 2026-05-04 06:08:31 UTC
;     dbname: control_plane_db
;     TOC Entries: 412
;     Compression: -1
;     Dump Version: 1.16-0
;     Format: CUSTOM
;     ...
Version compatibility

Custom-format v1.16 dumps come from Postgres 17+. Older pg_restore rejects them with unsupported version (1.16) in file header. On macOS, install with brew install postgresql@18 and use /opt/homebrew/opt/postgresql@18/bin/pg_restore.

Restoring locally

$ createdb my_local
$ pg_restore --no-owner --no-acl --dbname=my_local my-app.dump

--no-owner --no-acl ignores ownership and grants from the source — they'd reference the source's roles which don't exist in your local cluster.

Restoring back to a stack

If your goal is to seed another stack from this dump, see Restore. Don't scp a multi-GB file across the wire by hand — ownstack db restore --url=... hands the work to the stack.

Multi-stack apps

An app on multiple stacks has independent databases per stack. --stack=ID picks which one to dump. To capture all stacks, run the dump once per --stack.

What if my app uses MySQL?

Same command. The control-plane endpoint detects type from the app's config and runs dokku mysql:export instead. Output is gzipped SQL (.sql.gz); restore with:

$ gunzip < dump.sql.gz | mysql my_local

Programmatic / CI use

The endpoint is plain HTTP streaming behind your auth token; CI can fetch directly without the CLI:

curl -sSL -H "Authorization: Bearer $OWNSTACK_TOKEN" \
  -o backup-$(date +%Y%m%d).dump \
  "$OWNSTACK_API_URL/api/apps/$APP_ID/data/export?stack_id=$STACK_ID"