15

Is there any way to dump a postgres db using psql only ( without pg_dump )? Thanks.

pgpv
  • 335
  • 2
  • 10
  • Why would you want to do that? – tscho Feb 24 '12 at 21:17
  • 2
    If the system you have access to, say a locked down Docker container, only has an older version of `pg_dump` you may run into a Pg server version mismatch – tantrix Jan 22 '21 at 19:33

2 Answers2

3

Theoretically you have access to all the data needed. In practice you're more likely to be able to dump/save some data using COPY command, but not the database schema, etc.

Note, that you do not have to have pg_dump on the same machine where your database server is, if it listens to the network. But well, I don't know why you even ask :)

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173
1

In theory you could run queries to extract the schema and then use those results to extract the data. But it wouldn't be easy to manipulate all of that into something usable for a restore using just psql.

PinnyM
  • 35,165
  • 3
  • 73
  • 81