【问题标题】:Heroku pgbackups: Syntax errors on localhost restoreHeroku pgbackups:本地主机还原上的语法错误
【发布时间】:2012-06-03 00:09:17
【问题描述】:

尝试恢复使用 heroku pgbackups -tool 制作的数据库备份。

我通过暴露网址下载备份:

$ heroku pgbackups:url 'backup-name'

创建数据库:

$ createdb 'dbname' -U postgres

并尝试从 *.dump 文件中恢复:

$ psql -U postgres -d 'dbname' -f *.dump

我最终会遇到以下类型的语法错误:

ERROR:  syntax error at or near "PGDMP"
...
ERROR:  invalid byte sequence for encoding "UTF8": 0x9d
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding"

好的,所以这与编码有关 - 但我该如何解决呢?

config/application.rb 和我的 postgres 服务器都将编码设置为 UTF-8。 database.yml 已为其配置了 sqlite(尚未涉及生产配置)。 Gemfile 很简单:

gem 'pg'

【问题讨论】:

    标签: ruby-on-rails-3 postgresql heroku


    【解决方案1】:

    我找到了答案directly from the manual

    $ curl -o latest.dump `heroku pgbackups:url`
    
    $ pg_restore --verbose --clean --no-acl --no-owner -h myhost -U myuser -d mydb latest.dump
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      • 2010-09-29
      • 2019-02-05
      • 2017-08-18
      • 2016-07-29
      • 2013-08-24
      • 2014-04-18
      相关资源
      最近更新 更多