> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cubby.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# cubby db

> Database management commands for Neon Postgres apps

# cubby db

Manage Neon Postgres databases for your apps. These commands require a Builder ($9.99/mo) or Pro ($19.99/mo) plan.

SQLite apps do not use these commands -- SQLite databases are auto-managed with no additional CLI needed.

## Subcommands

| Command              | Description                        |
| -------------------- | ---------------------------------- |
| `cubby db export`    | Export database as SQL or CSV      |
| `cubby db branch`    | Create or delete a database branch |
| `cubby db branches`  | List database branches             |
| `cubby db snapshot`  | Create a point-in-time snapshot    |
| `cubby db snapshots` | List snapshots                     |
| `cubby db restore`   | Restore from a snapshot            |

***

## cubby db export

Export a Neon database as SQL or CSV. Output goes to stdout by default, or to a file with `--output`.

### Usage

```bash theme={null}
cubby db export [flags]
```

### Flags

| Flag       | Short | Description                           | Default  |
| ---------- | ----- | ------------------------------------- | -------- |
| `--app`    | `-a`  | App name                              | Required |
| `--format` | `-f`  | Export format (`sql` or `csv`)        | `sql`    |
| `--output` | `-o`  | Output file path (defaults to stdout) | --       |

### Examples

```bash theme={null}
# Export as SQL to stdout
cubby db export --app my-app

# Export as SQL to a file
cubby db export --app my-app --output backup.sql

# Export as CSV
cubby db export --app my-app --format csv

# Pipe to another tool
cubby db export --app my-app | psql local-db
```

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

<Note>
  **SQLite apps:** The `cubby db export` CLI command is for Neon Postgres apps only. To export a SQLite database, use the **Export Data** button in the dashboard. SQLite export requires the app to be running.
</Note>

<Note>
  **Stopped apps:** If your app was stopped due to a plan downgrade, you can still export your Neon database from the dashboard regardless of your current plan.
</Note>

***

## cubby db branch

Create or delete a Neon database branch. Branches let you experiment with schema or data changes without affecting your main database.

### Usage

```bash theme={null}
cubby db branch [flags]
```

### Flags

| Flag            | Short | Description             | Default        |
| --------------- | ----- | ----------------------- | -------------- |
| `--app`         | `-a`  | App name                | Required       |
| `--branch-name` | --    | Name for the new branch | Auto-generated |
| `--delete`      | --    | Delete a branch by name | --             |

### Examples

```bash theme={null}
# Create a branch with auto-generated name
cubby db branch --app my-app

# Create a named branch
cubby db branch --app my-app --branch-name feature-test

# Delete a branch
cubby db branch --app my-app --delete feature-test
```

### Output

On success, the command prints the branch name and a connection string you can use to connect directly to the branch.

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

***

## cubby db branches

List all database branches for an app.

### Usage

```bash theme={null}
cubby db branches [flags]
```

### Flags

| Flag    | Short | Description | Default  |
| ------- | ----- | ----------- | -------- |
| `--app` | `-a`  | App name    | Required |

### Examples

```bash theme={null}
cubby db branches --app my-app
```

### Output

```
NAME                                CREATED                   DEFAULT
main                                Apr 1, 2026, 10:30 AM     yes
feature-test                        Apr 2, 2026, 02:15 PM

2 branch(es)
```

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

***

## cubby db snapshot

Create a point-in-time snapshot of your Neon database. Use snapshots as restore points before risky migrations or data changes.

### Usage

```bash theme={null}
cubby db snapshot [flags]
```

### Flags

| Flag    | Short | Description | Default  |
| ------- | ----- | ----------- | -------- |
| `--app` | `-a`  | App name    | Required |

### Examples

```bash theme={null}
# Create a snapshot before running a migration
cubby db snapshot --app my-app
```

### Output

```
Snapshot created
  Snapshot ID: snap-abc123
  Timestamp:   2026-04-02T14:30:00Z
  App:         my-app
```

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

***

## cubby db snapshots

List all database snapshots for an app.

### Usage

```bash theme={null}
cubby db snapshots [flags]
```

### Flags

| Flag    | Short | Description | Default  |
| ------- | ----- | ----------- | -------- |
| `--app` | `-a`  | App name    | Required |

### Examples

```bash theme={null}
cubby db snapshots --app my-app
```

### Output

```
ID                        NAME                                CREATED
snap-abc123               pre-migration-backup                Apr 1, 2026, 10:30 AM
snap-def456               weekly-backup                       Mar 25, 2026, 08:00 AM

2 snapshot(s)
```

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

***

## cubby db restore

Restore a Neon database from a snapshot. This is a non-destructive operation -- it creates a new branch at the snapshot point. Your original data is unchanged.

### Usage

```bash theme={null}
cubby db restore [flags]
```

### Flags

| Flag         | Short | Description                 | Default  |
| ------------ | ----- | --------------------------- | -------- |
| `--app`      | `-a`  | App name                    | Required |
| `--snapshot` | `-s`  | Snapshot ID to restore from | Required |

### Examples

```bash theme={null}
# Restore from a specific snapshot
cubby db restore --app my-app --snapshot snap-abc123
```

### Output

```
Restore complete
  Branch:     restore-snap-abc123
  Connection: postgres://...
  Restored:   from snapshot snap-abc123

Note: This is a non-destructive restore. A new branch was created
at the snapshot point. Your original data is unchanged.
```

### Tier

Builder ($9.99/mo) or Pro ($19.99/mo) required.

***

## Troubleshooting

### "403 Forbidden" or "PLAN\_LIMIT\_REACHED"

Your plan does not include Neon Postgres. Upgrade to Builder ($9.99/mo) or Pro ($19.99/mo) at [app.cubby.pro/billing](https://app.cubby.pro/billing).

### "App not found"

Check your app name with:

```bash theme={null}
cubby apps
```

### "No database configured"

This app uses SQLite, not Neon Postgres. The `cubby db` commands only work with Neon Postgres apps. SQLite databases are auto-managed and do not require CLI commands.

### "Not logged in"

Authenticate first:

```bash theme={null}
cubby login
```

## Related Commands

* [`cubby deploy`](/cli-reference/deploy) -- Deploy your app
* [`cubby secrets`](/cli-reference/secrets) -- Manage environment variables
* [`cubby apps`](/cli-reference/overview) -- List your apps
