# scribase export

Assembles a signed, runnable bundle for a Scribase environment: the database
archive, storage objects, auth users and policies, rendered as a Docker Compose
project or Kustomize manifests, with a manifest of SHA-256 digests over every
artifact and an HMAC-SHA256 signature.

An export is a background job. `export create` queues it; the control plane's
export worker dumps, packs and boot-checks the bundle, then marks it
`available`. `export download --wait` follows it to completion and saves the
bundle.

## Usage

```sh
scribase export [create] <org> <project> <env> [--format compose|kustomize] [--schema-only] [--no-storage] [--wait] [--out FILE]
scribase export list <org> [<project>]
scribase export get <org> <export>
scribase export download <org> <export> [--out FILE] [--wait] [--timeout SECONDS] [--force]
```

## Options

| Flag | Applies to | Description |
|---|---|---|
| `--format` | `create` | Output format: `compose` (default) or `kustomize` |
| `--schema-only` | `create` | Leave table data out of the database archive |
| `--no-storage` | `create` | Leave storage objects out of the bundle |
| `--wait` | `create`, `download` | Wait for the export to become available, then download it |
| `--out` | `create --wait`, `download` | Where to save the bundle (default `<export>.tar.gz`) |
| `--timeout` | `create --wait`, `download --wait` | Longest time to wait, in seconds (default 1800) |
| `--force` | `download` | Overwrite an existing output file |

## Examples

```sh
# Queue a Docker Compose export and print its record (state "requested")
scribase export acme store production

# Queue a Kustomize export, wait for it, and save the bundle
scribase export create acme store production --format kustomize --wait --out store.tar.gz

# Every export in the organization, or in one project
scribase export list acme
scribase export list acme store

# One export's manifest, including a short-lived signed download link once available
scribase export get acme ex-3f9a1c2b7d4e5f60

# Download an existing export
scribase export download acme ex-3f9a1c2b7d4e5f60 --out store.tar.gz
```

## States

| State | Meaning |
|---|---|
| `requested` | Queued for the export worker |
| `packing`, `verifying` | Being dumped and bundled, then boot-checked |
| `available` | Ready; `export get` returns a signed `download_url` |
| `failed` | The worker stopped; `error` says why |
| `expired` | Past its retention; the bundle file was removed |

`export download` refuses to overwrite an existing file unless you pass
`--force`. It writes to `<out>.part` and renames the file only after a complete
download, so an interrupted download never leaves a truncated bundle behind.

## Notes

- The API routes are `POST /v1/organizations/{org}/projects/{project}/environments/{env}/exports`,
  `GET /v1/organizations/{org}/exports`, `GET /v1/organizations/{org}/projects/{project}/exports`
  and `GET /v1/organizations/{org}/exports/{export}`. See [Exports](https://docs.scribase.com/docs/api/exports.md).
- The signed download link carries its own authorization and expires after a
  short time; run `export get` again for a fresh one.
- Exports need `SCRIBASE_EXPORT_SIGNING_KEY_ID` and `SCRIBASE_EXPORT_SIGNING_KEY`
  set on the control plane. Without them the create route answers `503`.
- Verify the manifest signature before you deploy an exported bundle to production.
