Skip to content

Databases

Creating a database

canopy database create <type> --env <environment_id>
canopy database show --env <environment_id>
canopy database rm --env <environment_id>

Each environment (root or service) can have one primary database - the real, durable database your deployed app talks to. Creating one provisions a real managed service and links it to the environment automatically; no manual connection wiring needed.

Supported engines

canopy database create psql --env <environment_id>
canopy database create mariadb --env <environment_id>
canopy database create mongo --env <environment_id>
typeEngine
psqlPostgreSQL
mariadbMariaDB
mongoMongoDB

psql also accepts --image/--image-version to use an alternate Postgres-compatible image (for example pgvector/pgvector for an app whose migrations need the vector extension).

Connecting your app

Creating a database injects its connection details as environment variables on the environment automatically - most apps only need DATABASE_URL. The exact variable set is engine-specific (and Dokku’s own), so rather than duplicate a list that can drift, check what’s actually there for your environment:

canopy variables list --env <environment_id> --reveal

These are regular environment variables like any other - see Environments & Services for how variables set/list work generally. A fresh deploy isn’t needed after creating a database; the variables are injected before the app’s next start.

Test databases

Separate from the primary database, an environment can also have an isolated test database - provisioned the same way, but only ever injected as TEST_DATABASE_URL into the ephemeral container used for build/test steps, never into the deployed app itself:

canopy test-database create <type> --env <environment_id>
canopy test-database show --env <environment_id>
canopy test-database rm --env <environment_id>

This is what to reach for if your build steps run a real test suite against a database and you don’t want it anywhere near production data.

Backups

Primary databases are backed up automatically every night - nothing to configure. If you ever need to restore from one, reach out.