6

I connect to my postgres server using psql "service=subscription". How do I use the service with pg_dump?

I tried to do the following: pg_dump -h "service=subscription" > /home/fogest/dump.out

This however did not work.

How should I be doing this?

Edit: The error when I do the following:

pg_dump -h "service=subscription" odyssey_prod > /u3/jhvisser/dump.out
pg_dump: [archiver (db)] connection to database "odyssey_prod" failed: could not translate host name "service=subscription" to address: Name or service not known
Randall
  • 339
  • 3
  • 18

1 Answers1

7

You can't use -h to specify a connection-string. It can only be an actual hostname or IP.

To connect to a service (or use any other connection string) just pass it as a non-switch argument:

pg_dump "service=subscription"

or (I know this is counter-intuitive) pass it as the database name:

pg_dump -d "service=subscription"

This works with any libpq client (psql, pg_restore, etc).

Craig Ringer
  • 11,525