How to use pg_dump with a connection uri / url?
Asked Answered
G

2

118

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?

Grateful answered 13/3, 2015 at 18:28 Comment(1)
If an answer solves your problem (such as the one by @Jorge Disaz) you should probably accept it.Kaplan
W
220
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.

Willianwillie answered 17/3, 2015 at 14:10 Comment(0)
R
35

This is for newer versions of pg_dump:

pg_dump -d postgres://username:password@my_postgres_server:5432/databasename > filename
Rubbery answered 31/8, 2021 at 16:23 Comment(1)
I did not need the -d flag, it worked anyway.Lavettelavigne

© 2022 - 2024 — McMap. All rights reserved.