0

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

我一直在遵循 Heroku 的详细说明: https://devcenter.heroku.com/articles/heroku-postgres-import-export和这里:https : //devcenter.heroku.com/articles/pgbackups#restoreing -from-backup但一直遇到一个对我来说似乎相当神秘的问题。

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

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

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

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
4

1 回答 1

3

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

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

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

于 2013-02-04T20:34:22.227 回答