Skip to content

Database commands

Database commands work with db units.

Waits until the database is reachable through the database server CLI.

Terminal window
dpl db wait app-db
dpl db wait app-db --timeout 120

The default timeout is 60 seconds.

Opens an interactive SQL console as the database user.

Terminal window
dpl db console app-db

Use --root to connect as the engine superuser:

Terminal window
dpl db console app-db --root

dpl runs the client inside the running db-server container with podman exec -it.

Dumps a database as the database user.

Terminal window
dpl db backup app-db app-db.sql
dpl db backup app-db app-db.sql.gz
dpl db backup app-db - | gzip > app-db.sql.gz

Use -z to force gzip:

Terminal window
dpl db backup app-db backup.sql -z

When the path is omitted, dpl writes SQL to stdout. Client messages go to stderr, so piping stays clean.

Drops the database, login user, and local unit state. It keeps the YAML config.

Terminal window
dpl db drop app-db

Without flags, dpl asks for confirmation and asks whether to create a backup first.

Use --yes for non-interactive runs:

Terminal window
dpl db drop app-db --yes

With --yes, dpl creates a gzip backup in <base>/backup before dropping.