从备份还原Heroku数据库失败

llew8vvj  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(165)

我尝试从Heroku的备份还原数据库,但失败了。
我是用他们的指示:
heroku pg:备份:还原b101数据库URL --应用程序示例-应用程序
但得到如下错误:

Restoring... !
An error occurred and the backup did not finish.  
pg_restore: creating FK CONSTRAINT "public.user_disciplines_usertoken_tokens usertoken_id_refs_id_a11f5e9d"
pg_restore: warning: errors ignored on restore: 16
pg_restore finished with errors  
waiting for download to complete
download finished successfully
Run heroku pg:backups:info r2192 for more details.

当我运行建议的命令时,我得到以下内容:

2022-08-31 15:09:55 +0000 pg_restore: connecting to database for restore
2022-08-31 15:09:55 +0000 pg_restore: creating EXTENSION "hstore"
2022-08-31 15:09:55 +0000 pg_restore: while PROCESSING TOC:
2022-08-31 15:09:55 +0000 pg_restore: from TOC entry 2; 3079 95267 EXTENSION hstore (no owner)
2022-08-31 15:09:55 +0000 pg_restore: error: could not execute query: ERROR:  Extensions can only be created on heroku_ext schema
2022-08-31 15:09:55 +0000 CONTEXT:  PL/pgSQL function inline_code_block line 7 at RAISE
2022-08-31 15:09:55 +0000 Command was: CREATE EXTENSION IF NOT EXISTS "hstore" WITH SCHEMA "public";
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 pg_restore: creating COMMENT "EXTENSION "hstore""
2022-08-31 15:09:55 +0000 pg_restore: from TOC entry 5891; 0 0 COMMENT EXTENSION "hstore"
2022-08-31 15:09:55 +0000 pg_restore: error: could not execute query: ERROR:  extension "hstore" does not exist
2022-08-31 15:09:55 +0000 Command was: COMMENT ON EXTENSION "hstore" IS 'data type for storing sets of (key, value) pairs';
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 pg_restore: creating EXTENSION "pg_stat_statements"
2022-08-31 15:09:55 +0000 pg_restore: from TOC entry 3; 3079 95394 EXTENSION pg_stat_statements (no owner)
2022-08-31 15:09:55 +0000 pg_restore: error: could not execute query: ERROR:  Extensions can only be created on heroku_ext schema
2022-08-31 15:09:55 +0000 CONTEXT:  PL/pgSQL function inline_code_block line 6 at RAISE
2022-08-31 15:09:55 +0000 Command was: CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "public";
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 
2022-08-31 15:09:55 +0000 pg_restore: creating COMMENT "EXTENSION "pg_stat_statements""
2022-08-31 15:09:55 +0000 pg_restore: from TOC entry 5892; 0 0 COMMENT EXTENSION "pg_stat_statements"
2022-08-31 15:09:55 +0000 pg_restore: error: could not execute query: ERROR:  extension "pg_stat_statements" does not exist
2022-08-31 15:09:55 +0000 Command was: COMMENT ON EXTENSION "pg_stat_statements" IS 'track planning and execution statistics of all SQL statements executed';

因此,看起来问题是与hstore扩展和最近Heroku做了一些更改:https://devcenter.heroku.com/changelog-items/2446
我联系了Heroku支持,但还没有得到回复。也许有人有办法处理这个问题?

lrl1mhuk

lrl1mhuk1#

以下解决方案有效:
恢复包括安装在公共位置的扩展的备份

heroku pg:backups:restore <BACKUP_ID> <DATABASE_NAME> --extensions '<LIST_OF_EXTENSIONS>' -a <APP_NAME>

例如:

heroku pg:backups:restore b010 STAGING_DATABASE_URL --extensions 'pg_stat_statements,hstore,pgcrypto' -a example_app

更多详细信息,请访问:https://help.heroku.com/ZOFBHJCJ/heroku-postgres-extension-changes-faq

相关问题