Skip to main content
Connections can also be managed from the interactive TUI (just run capsule with no arguments). Use the connection subcommands when you want to script or automate setup — e.g. provisioning a new server with Ansible, cloud-init, or a Docker entrypoint.

Subcommands


capsule connection add

Adds a new database connection. Fails immediately — before prompting for any secret — if your plan’s connection limit has already been reached.

Flags

Postgres / MySQL example

You’ll be prompted for the password with input hidden:

MongoDB example

If --uri isn’t passed, you’ll be prompted for the full connection string with input hidden (it contains embedded credentials):
For fully non-interactive setups (provisioning scripts, CI), set CAPSULE_CONN_PASSWORD or CAPSULE_CONN_URI as environment variables instead of being prompted. Neither is ever written to shell history since they’re read from the environment, not a flag.

Server migration safety check

The dashboard identifies a connection by its host, port, and database — not its label. So if you migrate a database to a new server and re-add it there with the same label you used before, add won’t know to update the old entry; it’ll otherwise create a second, orphaned-looking connection with a duplicate label pointing at the old, now-decommissioned server. To catch this, add checks the dashboard for an existing connection with the same label under a different host/port/database before proceeding:
If you’re intentionally migrating, pass --force to proceed anyway. If not, the safer fix is usually to remove the stale connection (from the old server if it’s still reachable, or via the dashboard if it’s already gone) before adding the new one — see Migrating to a new server below.

capsule connection list

Lists all configured connections along with your plan’s connection usage, 10 per page by default.

Flags

Once you’re past the first page, the command prints the exact command to run for the next one. Requesting a page beyond the last one is an error, not an empty list — so a script checking the exit code can reliably tell “no more pages” from “something’s wrong.”

capsule connection update

Updates one or more fields on an existing connection in place — same connection ID, so any schedule attached to it is untouched. Use this instead of remove + add when credentials rotate or a host changes, since remove deletes the associated schedule too.

Flags

Only the flags you pass are changed — everything else is left as-is. At least one field (or a password/URI rotation) must be given, or the command errors out.

Rotating a password

For non-interactive use (Ansible, CI), set CAPSULE_CONN_PASSWORD (or CAPSULE_CONN_URI for mongo) instead of passing --rotate-password — if either is set, the update applies it without any prompt:

Changing a host


capsule connection remove

Removes a connection and its associated schedule (if any). This also live-reloads the running daemon so the change takes effect immediately, without interrupting an in-flight backup — see capsule schedule for details on how that works.
This only removes the connection from Capsule — your actual database is never touched.

Migrating to a new server

Moving a database to a new server involves two independent pieces of state: the dashboard’s connection record (identified by host/port/database, not label) and each server’s local config (connections.json, schedules) — neither carries over automatically. Recommended order:
Removing the old connection first means the new add never has anything to collide with, and you skip the safety-check error entirely. If the old server is already gone before you could run remove there, the orphaned entry needs to be deleted manually from the dashboard’s Connections page instead — then add the new one as above.
If the host/port/database stay identical across the move (e.g. a floating IP or DNS name that gets repointed to the new server), re-adding it there updates the existing dashboard entry in place instead of creating a new one — no --force or cleanup needed. Schedules still need to be re-created locally either way, since they’re per-machine state.

Notes

  • Connections are stored locally in ~/.local/share/capsule/connections.json, encrypted at rest
  • Every successful add, update, and remove syncs to your dashboard automatically; a sync failure (e.g. offline) is logged as a warning but doesn’t block the local change
  • Plan connection limits: Hobbyist = 1, Solo = 3, Pro = 6
  • Hobbyist and Solo plans are restricted to local databases — a host of localhost, 127.0.0.1, ::1, 0.0.0.0, or a Unix socket path. Pointing --host at anything else (e.g. a separate database server, a managed RDS instance) on those plans fails with remote connections require the Pro plan or higher. This matters most for the common “app server and database on separate machines” setup — that needs Pro or Team, even if you’re otherwise within your connection-count limit.

See also

  • capsule schedule — schedule automatic backups for a connection you’ve added
  • capsule doctor — verify the required database client tools are installed before adding a connection