Create a new instance whose data is copied from an existing one, streamed as a pg_dump | pg_restore pipe — no temp file on disk.
# Clone the default instance
pg clone test02
# Clone a specific instance
pg clone test02 -i proj01
# Clone a remote database via connection string
pg clone test02 --dsn postgres://user:pass@host:5432/db
# Custom data directory for the new instance
pg clone test02 -i proj01 --base-dir /data/pg- Pre-flight check — the source is verified before anything is created:
- Local instance: container must be running
--dsn: an authenticatedSELECT 1must succeed (catches wrong password, unreachable host)
- Create — a new instance entry is added to the config with a random password, its own container name, data directory and auto-assigned port
- Start — the new instance is started (same workflow as
pg start) - Stream —
pg_dump(source) is piped intopg_restore(target) with live transfer progress shown once per second
- The source instance must be running (or the
--dsntarget reachable); a bad source fails immediately with no side effects - The new instance name must not already exist in config
--dsnand--instanceare mutually exclusive: with--dsnthe connection string determines host, port and database- The new instance gets a fresh random password — find it in the clone output or
pg status -i <name> - Logical copy only (schema + data via pg_dump); for large databases a physical approach may be faster