将本地postgresql数据库数据复制到远程heroku数据库的问题

时间:2021-08-14 23:31:04

I have a Heroku app with a postgresql database I'm trying to pre-populate with data created on my localhost postgresql installation.

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

I've been following the instructions from Heroku detailed both here: https://devcenter.heroku.com/articles/heroku-postgres-import-export and here: https://devcenter.heroku.com/articles/pgbackups#restoring-from-backup but keep running into an issue that seems rather cryptic to me.

我一直按照Heroku的说明进行详细说明:https://devcenter.heroku.com/articles/heroku-postgres-import-export and here:https://devcenter.heroku.com/articles/pgbackups#restoring - 从备份,但继续遇到一个似乎相当神秘的问题。

First, I've created my local database dumb using this command:

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

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

I then followed the instructions to upload my dump file to a Cloud App url and try to then restore the database with the following command:

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

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

The following output the prints with an error: Retrieving... done

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

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

When I look at the logs, I see this output below which is complaining about an integer, and then a "invalid path", but I can't make sense why. The URL to the dump file is correct and accessible.

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

Any insight into this problem is much appreciated!

任何洞察这个问题的人都非常感谢!

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 个解决方案

#1


3  

The default cloudapp urls are 30x redirects, and unfortunately at the time of this answer, pgbackpus doesn't follow redirects. I should get around to fixing that sometime, but in the mean time, do a curl -I on your cloudapp url and find the real url, and use that.

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

The hint there is the "invalid path" in the logs at the bottom.

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

Also for what it's worth, if you have the backup locally already, and it's not so big, you can just use pg_restore from your machine on the remote pg database.

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

#1


3  

The default cloudapp urls are 30x redirects, and unfortunately at the time of this answer, pgbackpus doesn't follow redirects. I should get around to fixing that sometime, but in the mean time, do a curl -I on your cloudapp url and find the real url, and use that.

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

The hint there is the "invalid path" in the logs at the bottom.

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

Also for what it's worth, if you have the backup locally already, and it's not so big, you can just use pg_restore from your machine on the remote pg database.

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