2

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
  • "Did not work". What, exactly, did not work - what happened or did not happen? Do you have a ~/.pg_service.conf file? – Craig Ringer Apr 10 '14 at 2:01
  • @CraigRinger Yes I have a pg_service file. I updated the original post with details. – ComputerLocus Apr 10 '14 at 2:22
  • PostgreSQL version and OS? – Craig Ringer Apr 10 '14 at 2:32
  • What happens when you use connection options with pg_dump the same way you used them with psql, e.g. pg_dump "service=subscription" ... ? – Milen A. Radev Apr 10 '14 at 4:23
  • @CraigRinger I currently can't check, but it should be running the latest version and on Ubuntu 12.04. I can check the version later if needed. – ComputerLocus Apr 10 '14 at 13:48
2

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:

psql "service=subscription"

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

psql -d "service=subscription"
  • Okay, but does this work with pg_dump? – ComputerLocus Apr 10 '14 at 14:15
  • Yes; any libpq client. – Craig Ringer Apr 10 '14 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.