This page summarizes the current command surface exposed by ditto.
ditto [command]
Global flags:
| Flag | Meaning |
|---|---|
--config <path> |
Path to ditto.yaml. If omitted, ditto searches ./ditto.yaml, ~/.ditto/ditto.yaml, then /etc/ditto/ditto.yaml. |
--db <path> |
Path to the SQLite metadata database |
--version |
Print version information |
Shared-host clients may set DITTO_SERVER instead of passing --server on every supported command.
An explicit --server flag takes precedence.
Create a clean copy from the latest dump or from --dump.
ditto copy create
ditto copy create --format=json --ttl 30m
ditto copy create --dump s3://bucket/latest.gzFlags:
| Flag | Meaning |
|---|---|
--dump <uri> |
Restore from a local path, s3://, or https:// source. In remote mode (--server), local filesystem paths are rejected — use a URI. |
--format <mode> |
Output style: auto, pipe, or json |
--label <name> |
Run identifier override |
--obfuscate |
Apply configured obfuscation post-restore |
--ttl <duration> |
Override lifetime for this copy |
--server <url> |
Use a shared ditto host; bearer token comes from DITTO_TOKEN |
Create a copy, run one command with DATABASE_URL injected, and destroy the copy on exit.
ditto copy run -- go test ./...
ditto copy run --ttl 30m -- sh -c 'migrate -database "$DATABASE_URL" up'If the child command needs shell expansion, invoke a shell explicitly as in the second example.
Injected environment variables:
DATABASE_URLDITTO_COPY_ID
Flags:
| Flag | Meaning |
|---|---|
--dump <uri> |
Restore from a specific source. In remote mode (--server), must be a URI (s3://, https://), not a local path. |
--label <name> |
Run identifier override |
--obfuscate |
Apply configured obfuscation post-restore |
--ttl <duration> |
Override lifetime for this copy |
--server <url> |
Use a shared ditto host; bearer token comes from DITTO_TOKEN |
ditto copy list
ditto copy delete <id>
ditto copy logs <id>Use copy list to inspect active copies and copy logs for lifecycle events tied to a specific ID.
Refresh the local dump immediately:
ditto reseedThis command succeeds only after a new dump completes successfully.
Run the shared-host controller:
ditto hostResponsibilities:
- refresh the dump on the configured schedule
- delete copies after TTL expiry
- refill the warm pool when enabled
- recover stuck copies and orphan containers on startup
- serve the authenticated
/v2API for remote callers
Check that all prerequisites are satisfied before running other commands:
ditto doctor
ditto doctor --server http://ditto.internal:8080Verifies:
- Docker daemon is reachable
- Configuration is loaded and source fields are present
- Dump file exists and is not stale
- Source database is reachable (TCP + query)
- OIDC JWKS endpoint is reachable (when
server.authis configured)
Prints a green/red checklist and exits non-zero if any check fails. Run this first when something is not working.
With --server or DITTO_SERVER, doctor validates the shared host and bearer token without
requiring local Docker, local source config, or a local dump file.
Generate a starter ditto.yaml in the current directory:
ditto init
ditto init --output ~/.ditto/ditto.yamlIf DITTO_SOURCE_URL is set, source fields are pre-populated from it. Obfuscation rule stubs are
included as comments. After editing, verify the result with ditto doctor.
Flags:
| Flag | Meaning |
|---|---|
--output <path> |
Write path (default: ditto.yaml in the current directory) |
Show dump freshness and copy capacity:
ditto statusUse ditto doctor for a deeper diagnostic that includes source connectivity and OIDC checks.
Refresh a configured target database from the latest dump:
ditto target refresh staging --confirm staging
ditto target refresh staging --dump s3://bucket/latest.gz --confirm staging
ditto target refresh staging --dry-run --confirm stagingFlags:
| Flag | Meaning |
|---|---|
--confirm <name> |
Required confirmation; must match the target name |
--dump <uri> |
Restore from a local path, s3://, or https:// source. In remote mode, local paths are rejected. |
--dry-run |
Validate the request without cleaning or restoring |
--obfuscate |
Apply configured obfuscation rules after restore |
--server <url> |
Use a shared ditto host; bearer token comes from DITTO_TOKEN |
Target refresh is destructive. The target must set allow_destructive_refresh: true in
ditto.yaml.
Use env when you want shell-friendly environment management.
Create a copy and print shell export lines:
eval "$(ditto env export)"This sets DATABASE_URL and DITTO_COPY_ID in the current shell.
Destroy a copy created with env export:
ditto env destroy "$DITTO_COPY_ID"Run one command with DATABASE_URL injected:
ditto env -- pytest tests/env -- is effectively the same lifecycle as copy run.
Generate an ERD from a temporary copy or directly from the source database:
ditto erd
ditto erd --format=dbml --output schema.dbml
ditto erd --sourceFlags:
| Flag | Meaning |
|---|---|
--format <type> |
Output format: mermaid or dbml |
--output <path> |
Write output to a file |
--source |
Connect to the source database directly |
--server <url> |
Create the temporary copy via a shared ditto host |