将本地postgresql数据库数据复制到远程heroku数据库时出现问题

时间:2013-02-04 20:24:45

标签: ruby-on-rails ruby heroku

我有一个带有postgresql数据库的Heroku应用程序我正在尝试预先填充在我的localhost postgresql安装中创建的数据。

我一直在按照Heroku的说明进行详细说明:https://devcenter.heroku.com/articles/heroku-postgres-import-export和此处:https://devcenter.heroku.com/articles/pgbackups#restoring-from-backup但仍然遇到一个对我来说似乎相当神秘的问题。

首先,我使用以下命令创建了我的本地数据库:

PGPASSWORD=password pg_dump -o -Fc --no-acl --no-owner -h localhost -U dbUser db_name > db/db_name.dump

然后我按照说明将我的转储文件上传到Cloud App网址,然后尝试使用以下命令恢复数据库:

heroku pgbackups:restore DATABASE_NAME 'http://path/to/db_name.dump' --app app_name

以下输出带有错误的打印件: 检索......完成

 !    An error occurred and your restore did not finish.
 !    Please run `heroku logs --ps pgbackups` for details.

当我查看日志时,我看到下面的输出正在抱怨整数,然后是“无效路径”,但我无法理解为什么。转储文件的URL是正确且可访问的。

非常感谢对这个问题的任何见解!

2013-02-04T20:15:06+00:00 app[pgbackups]: Started:  Mon Feb 4 20:15:06 UTC 2013
2013-02-04T20:15:06+00:00 app[pgbackups]: Location: e9d564f0-a67f-4c32-bad5-60798786b87b:/tmp/VFJ5WDiAHr
2013-02-04T20:15:07+00:00 app[pgbackups]: psql: bin//psql-9.2.1-64bit
2013-02-04T20:15:07+00:00 app[pgbackups]: pv: bin//pv-1.1.4-64bit
2013-02-04T20:15:07+00:00 app[pgbackups]:       SELECT count(*) = 0 as is_empty
2013-02-04T20:15:07+00:00 app[pgbackups]:       FROM pg_class INNER JOIN pg_roles ON relowner = pg_roles.oid
2013-02-04T20:15:07+00:00 app[pgbackups]:       WHERE rolname <> '\''postgres'\'''
2013-02-04T20:15:07+00:00 app[pgbackups]: bin/brie: line 145: [: 9.1: integer expression expected
2013-02-04T20:15:07+00:00 app[pgbackups]: pg_restore: bin//pg_restore-9.1.6-64bit
2013-02-04T20:15:07+00:00 app[pgbackups]:  Schema |             Name              | Type  |       Info        
2013-02-04T20:15:07+00:00 app[pgbackups]: --------+-------------------------------+-------+-------------------
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | abilities                     | table | 554
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | abilities                     | table | abilities_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | champions                     | table | 110
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | champions                     | table | champions_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | effects                       | table | 934
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | effects                       | table | effects_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | items                         | table | 191
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | items                         | table | items_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | masteries                     | table | 56
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | masteries                     | table | masteries_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | runes                         | table | 305
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | runes                         | table | runes_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | schema_migrations             | table | 26
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | schema_migrations             | table | 
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | spells                        | table | 15
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | spells                        | table | spells_pkey
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | abilities_pkey                | index | abilities
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | champions_pkey                | index | champions
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | effects_pkey                  | index | effects
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_champions_on_updated_at | index | champions
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_items_on_item_id        | index | items
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_items_on_updated_at     | index | items
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_masteries_on_updated_at | index | masteries
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_runes_on_updated_at     | index | runes
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | index_spells_on_updated_at    | index | spells
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | items_pkey                    | index | items
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | masteries_pkey                | index | masteries
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | runes_pkey                    | index | runes
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | spells_pkey                   | index | spells
2013-02-04T20:15:07+00:00 app[pgbackups]:  public | unique_schema_migrations      | index | schema_migrations
2013-02-04T20:15:07+00:00 app[pgbackups]: (30 rows)
2013-02-04T20:15:07+00:00 app[pgbackups]: 
2013-02-04T20:15:07+00:00 app[pgbackups]: download_progress: start
2013-02-04T20:15:07+00:00 app[pgbackups]: download_progress:    0B 
2013-02-04T20:15:07+00:00 app[pgbackups]: 
2013-02-04T20:15:07+00:00 app[pgbackups]: download_progress: 0.0bytes
2013-02-04T20:15:07+00:00 app[pgbackups]: download_progress: done
2013-02-04T20:15:07+00:00 app[pgbackups]: Invalid path

1 个答案:

答案 0 :(得分:3)

默认的cloudapp网址是30x重定向,不幸的是,在这个回答时,pgbackpus不遵循重定向。我应该在某个时候解决这个问题,但与此同时,在你的cloudapp网址上做一个curl -I并找到真正的网址,并使用它。

提示底部的日志中存在“无效路径”。

同样值得一提的是,如果你已经在本地进行备份,并且它不是那么大,你可以在远程pg数据库的机器上使用pg_restore