2

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' ?

2
  • Why have you tagged everything under sun. Please remove the irrelevant tags Commented Oct 3, 2016 at 20:30
  • .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? Commented Oct 3, 2016 at 20:33

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.