在开发中使用heroku pg_dump

时间:2013-12-28 00:10:43

标签: ruby-on-rails postgresql heroku pg-dump pg-restore

我正在尝试在我的开发环境中使用来自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)

1 个答案:

答案 0 :(得分:0)

使用--data-only修饰符:

  

-a   --data-only仅还原数据,而不还原模式(数据定义)。如果,则恢复表数据,大对象和序列值   存在于档案中。

     

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