0

我正在尝试在我的开发环境中使用 heroku 的 pg_dump。

似乎我可以在下载转储后使用 pg_restore 来执行此操作: http ://www.postgresql.org/docs/current/static/app-pgrestore.html

我无法正确使用该实用程序,可能有人可以在这里帮助我

这是我正在使用的命令:

➜  myapp git:(master) ✗ pg_restore --dbname=myapp_development ~/Downloads/2013-12-27-06-04-23.dump

我得到一堆模式已经存在,角色不存在错误。

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 181; 1259 4558648 TABLE authentications hsddtzyenpyiuasdu
pg_restore: [archiver (db)] could not execute query: ERROR:  relation "authentications" already exists


ERROR:  relation "authentications_id_seq" already exists

pg_restore: [archiver (db)] could not execute query: ERROR:  role "hsddtzyenpyiuasdu" does not exist

我敢打赌,有一种更简单、更清洁的方法可以做到这一点。如果有人提供能够在开发中使用 prod heroku pg db 的步骤和命令列表,将不胜感激。

谢谢 PS:数据量和架构量极小(转储:6MB)

4

1 回答 1

0

使用--data-only修饰符:

-a --data-only 只恢复数据,不恢复模式(数据定义)。如果存档中存在表数据、大对象和序列值,则会恢复。

此选项与指定 --section=data 类似,但由于历史原因并不完全相同。

于 2013-12-28T01:17:42.817 回答