In pg_restore, how can you use a postgres connection string to specify the host/database/username/password?
In PostgreSQL tools wherever you can specify a database name you can instead specify a connection string.
In the syntax for pg_restore
the dbname is passed with a flag, not as a positional parameter:
$ pg_restore --helppg_restore restores a PostgreSQL database from an archive created by pg_dump.Usage: pg_restore [OPTION]... [FILE]General options: -d, --dbname=NAME connect to database name ...
so you should be using:
pg_restore -d 'postgres://userb:somepassword@somehost.com:5432/otherdatabase' dump.dump
Yes, that user interface mismatch between pg_dump
and pg_restore
sucks, and I wish we could change it, but it's a bit late now.