0
votes

I want to create a .dump file from a Postgres .sql file I have locally. I don't want to connect to the database to do so, I just have a local file (or remote, wouldn't really matter), that I want to convert from .sql to .dump (so I can then upload to Heroku with PG backups).

From what I've seen and read you must connect to the database in order to create a dump. Is it possible to convert a .sql file > .dump file without connecting to it?

Something like pg_dump -f '/my/local/path.sql' > 'my-output-file.dump' ?

1
Why have you tagged everything under sun. Please remove the irrelevant tags - Pரதீப்
.dump should be just the sql commands necessary to recreate the tables and populate them, which is what that .sql should be already anyways. Have you considered all you really need is mv foo.sql foo.dump? - Marc B

1 Answers

1
votes

There is no way to create a PostgreSQL custom format dump (what you call a ".dump file") from a script file (what you call a ".sql file") other than loading the latter into a PostgreSQL database and then extracting it with pg_dump -Fc.

The opposite, creating a SQL script from a custom format dump, can be done with pg_restore.