Skip to content

tenant db command group

tenant db manages a tenant's optional dedicated database-source configuration in {{ product_name }}. By default a tenant uses the shared database; these commands view, create or update, delete, back up, and restore the per-tenant dedicated DB-source. Every subcommand targets a single tenant by its UUID (-u/--uuid).

Remote command — requires a host profile and login

The alpine-admin-cli is a remote gRPC client. Every tenant db command talks to a server, so you must first create a host profile with profile hosts create and authenticate with profile authn login. Host connection profiles — including their embedded OIDC logins (with PIN-sealed tokens) — are stored under ${HOME}/.config/alpinepki/hosts/. Select a specific profile for a single command with the global -p/--profile option (default default-admin), placed before the command path.

The DB password is never returned

tenant db view and tenant db backup never expose the stored database password. view reports only whether a password is configured (password_configured), and backup redacts the password server-side. To set or rotate the password, supply --db-password to tenant db update.

Commands in this group

Command Purpose
tenant db view Display a tenant's dedicated database configuration
tenant db update Create or update a tenant's dedicated database configuration
tenant db delete Delete the dedicated DB-source (revert to the shared DB)
tenant db backup Back up the dedicated DB configuration to a binary .pb file
tenant db restore Restore the dedicated DB configuration from a .pb backup

Command group help

bin/admin.sh tenant db --help

tenant db view

Displays a tenant's dedicated database-source configuration. The DB password is never returned; its presence is reported via password_configured.

Syntax

bin/admin.sh tenant db view [options]

Required options

Option Description
-u, --uuid UUID of the tenant

Optional options

Show optional options
Option Default Description
-f, --out-format YAML Output format: JSON or YAML

Example

bin/admin.sh tenant db view -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f -f json

tenant db update

Creates or updates a tenant's dedicated database-source. The command performs a partial merge: the tenant's current configuration is fetched and the supplied --db-* options are applied on top. When the tenant has no dedicated DB-source yet, the options are applied onto an empty configuration (create). A supplied --db-password is stored; when omitted, the stored password is preserved by the backend.

Syntax

bin/admin.sh tenant db update [options]

Required options

Option Description
-u, --uuid UUID of the tenant

Optional options

Show optional options
Option Default Description
--db-server unchanged Database server host
--db-port unchanged Database server port
--db-database unchanged Database name
--db-user unchanged Database user
--db-password preserve stored Database password (leave unset to preserve the stored one)
--db-schema unchanged Database schema
--db-pool-name unchanged Connection pool name
--db-class-name unchanged JDBC data-source class name
--db-catalog unchanged Database catalog
--[no-]db-ssl unchanged Use SSL for the database connection
--db-ssl-mode unchanged SSL mode: DISABLE, ALLOW, PREFER, REQUIRE, VERIFY_CA, or VERIFY_FULL
--[no-]db-read-only unchanged Open the data source read-only
--[no-]db-auto-commit unchanged Enable auto-commit
-f, --out-format YAML Output format: JSON or YAML

Validation rules

  • Every --db-* option is optional and applied as a partial merge: an unset option leaves the corresponding field unchanged on an existing configuration, or empty when creating a new DB-source.
  • Leaving --db-password unset preserves the password already stored for the tenant.
  • --db-ssl-mode accepts only DISABLE, ALLOW, PREFER, REQUIRE, VERIFY_CA, or VERIFY_FULL.
  • The boolean toggles --db-ssl, --db-read-only, and --db-auto-commit are negatable; use the --no- prefix (for example --no-db-ssl) to set the field to false.
  • This mixin exposes the common connection knobs; the full configuration can be round-tripped with tenant db backup and tenant db restore.

Example (create or update connection settings)

bin/admin.sh tenant db update \
  -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f \
  --db-server tenant-db.example.com \
  --db-port 5432 \
  --db-database tenant_alpha \
  --db-user alpine_svc \
  --db-password <new-password> \
  --db-schema alpine \
  --db-ssl \
  --db-ssl-mode VERIFY_FULL \
  -f json

Example (rotate password only, preserving other fields)

bin/admin.sh tenant db update \
  -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f \
  --db-password <new-password> \
  -f yaml

tenant db delete

Deletes a tenant's dedicated database-source; the tenant reverts to the shared database.

Syntax

bin/admin.sh tenant db delete [options]

Required options

Option Description
-u, --uuid UUID of the tenant

Optional options

Show optional options
Option Default Description
-f, --out-format YAML Output format: JSON or YAML

Example

bin/admin.sh tenant db delete -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f -f json

tenant db backup

Backs up a tenant's dedicated database-source configuration to a binary protobuf (.pb) file. The backup never contains the DB password (it is redacted server-side). Output goes to a file (-o) or to the console as Base64 (-s); choose exactly one.

Syntax

bin/admin.sh tenant db backup [options]

Required options

Option Description
-u, --uuid UUID of the tenant

Required output destination options (choose exactly one)

Option Description Example
-o, --output-file Write the .pb backup to a file (creates or truncates) -o ./tenant-alpha-db.pb
-s, --print-to-screen Print the backup to the console as Base64 -s true

Validation rules

  • Supply exactly one of -o/--output-file or -s/--print-to-screen; the output-destination group has multiplicity 1.
  • With -s/--print-to-screen, the binary .pb payload is emitted Base64-encoded so it can be captured from the terminal.

Optional options

Show optional options
Option Default Description
-f, --out-format YAML Output format for error reporting: JSON or YAML

Example

bin/admin.sh tenant db backup \
  -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f \
  -o ./tenant-alpha-db.pb

tenant db restore

Restores a tenant's dedicated database-source configuration from a binary protobuf (.pb) backup.

Syntax

bin/admin.sh tenant db restore [options]

Required options

Option Description Example
-u, --uuid UUID of the tenant -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f
-i, --input-file .pb backup file to restore -i ./tenant-alpha-db.pb

Optional options

Show optional options
Option Default Description
-f, --out-format YAML Output format: JSON or YAML

Validation rules

  • When the backup omits the password, the stored password is preserved for a tenant that already has a DB-source.
  • Restoring a password-less backup onto a tenant with no existing DB-source is rejected (the source could not authenticate). Re-enter a password with tenant db update in that case.

Example

bin/admin.sh tenant db restore \
  -u 7c2f1e6a-9b3d-4f0a-8e21-5a6b7c8d9e0f \
  -i ./tenant-alpha-db.pb \
  -f json

Standard CLI options are documented in Global options.

FAQ

Does tenant db view show the database password?

No. The password is never returned. tenant db view reports only whether a password is configured via the password_configured field, and tenant db backup redacts the password server-side.

How do I revert a tenant to the shared database?

Run tenant db delete -u <tenant-uuid>. This removes the tenant's dedicated DB-source so the tenant uses the shared database again.

Do I have to supply every --db-* option on tenant db update?

No. tenant db update performs a partial merge. Only the options you supply are applied; unset options leave the existing fields unchanged, and an unset --db-password preserves the stored password.

Why is my tenant db restore rejected for a password-less backup?

A backup never contains the password. Restoring a password-less backup onto a tenant that has no existing DB-source is rejected because the source could not authenticate. Set a password with tenant db update first.