How can I get a plain text postgres database dump on heroku?

前端 未结 5 1426
猫巷女王i
猫巷女王i 2020-12-07 14:14

Due to version incompatibilities of my postgres database on heroku (9.1) and my local installation (8.4) I need a plain text sql database dump file so I can put a copy of my

5条回答
  •  萌比男神i
    2020-12-07 14:33

    Heroku's PGBackups actually uses pg_dump behind the scenes, and the "custom format" is actually pg_dump's custom format (-Fc parameter), not Heroku's own custom format.

    This means you can use pg_restore, which is part of Postgres, to restore your Heroku backup into another database directly:

    pg_restore -d mydatabase my_dump_file.dump
    

    In addition, if you call pg_restore without specifying a database to restore to, it'll print SQL statements to standard out, so you can turn your Heroku backup into a SQL file that way:

    pg_restore my_dump_file.dump > sql_statements.sql
    

提交回复
热议问题