How to restore pg_dump file into postgres database

后端 未结 1 906
你的背包
你的背包 2021-01-22 11:42

So I regularly backup and restore databases and schema\'s using pgadmin4. I would like to do it with a batch file using commands as pg_dump and pg_restore. I however always fail

相关标签:
1条回答
  • 2021-01-22 12:18

    https://www.postgresql.org/docs/current/static/app-pgrestore.html

    --format=format Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following:

    custom, directory and tar

    https://www.postgresql.org/docs/current/static/app-pgdump.html

    --format=format

    Selects the format of the output. format can be one of the following:

    p plain Output a plain-text SQL script file (the default).

    others are custom, directory and tar

    in short - you used defualt plain format, which is meant for using with psql, not pg_restore. So either specify different format with pg_dump or use your file as

    psql -f  mw2.tar
    
    0 讨论(0)
提交回复
热议问题