114

I can invoke psql like this:

psql postgres://...

How can I use pg_dump with a connection string in the format postgres://...?
Would be more convenient than breaking URI's into host, post, username, password.

Is there syntax for this?

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Tronathan
  • 6,473
  • 5
  • 22
  • 24

2 Answers2

211
pg_dump postgres://username:password@my_postgres_server:5432/databasename

I just downloaded a dump using this format. Optionally you can add -f filename to specify a local filename.

Emil Laine
  • 41,598
  • 9
  • 101
  • 157
Jorge Diaz
  • 2,503
  • 1
  • 14
  • 15
29

This is for newer versions of pg_dump:

pg_dump -d postgres://username:password@my_postgres_server:5432/databasename > filename
Mohammad Barbast
  • 1,753
  • 3
  • 17
  • 28