3

我正在尝试将笔记本电脑上的开发数据库传输到工作站。它给了我各种各样的错误,我不知道如何正确恢复这个数据库转储。没有-1它确实完成了,但是丢失了很多对象。

目标机器上的数据库名称与我转储的数据库不同。但我看不出与错误有什么关系。这个转储/恢复的东西是全新的。pg_restore -l在我没有线索的情况下,我看不到有关系统目录的任何内容...

D:\db>pg_restore -d checkpoint -U postgres --disable-triggers -x -O -
1 -v -n temp dump-1.backup
pg_restore: connecting to database for restore
Password:
pg_restore: creating TYPE "temp.my_agg"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1037; 1247 89882 TYPE my_agg po
stgres
pg_restore: [archiver (db)] could not execute query: ERROR:  permission denied t
o create "pg_catalog.my_agg"
DETAIL:  System catalog modifications are currently disallowed.
    Command was: CREATE TYPE my_agg AS (
        ecnt integer,
        eids integer
);

drop-n temp似乎摆脱了特权问题。但还有更多错误出现

pg_restore: creating FUNCTION "public.cmptime(timestamp without time zone, text,
 timestamp without time zone, text, text)"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 355; 1255 60129 FUNCTION cmptim
e(timestamp without time zone, text, timestamp without time zone, text, text) po
stgres
pg_restore: [archiver (db)] could not execute query: ERROR:  language "plv8" doe
s not exist
    Command was: CREATE FUNCTION cmptime(t0 timestamp without time zone, s0 text
, t1 timestamp without time zone, s1 text, rcode text) RETURN...

在手动创建 plv8 和 plpython 扩展之后。那些语言错误已经消失了。我对这个 FDW 表有疑问。

pg_restore: creating FOREIGN TABLE "public.t1"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 204; 1259 25543 FOREIGN TABLE r
edrawing postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  server "myserver1"
does not exist
    Command was: CREATE FOREIGN TABLE t1 (
    fid bigint,
    pd_date text,
    team text,
    shift text,
    line text,
    opr1 te...

我试图创建 FDW 扩展。但 FDW 依赖于公共模式。删除-c --if-existspg_restore 选项,在每次还原尝试之前重新创建检查点数据库。

pg_restore: [archiver (db)] could not execute query: ERROR:  server "myserver1"
does not exist
    Command was: CREATE FOREIGN TABLE t1 (
    fid bigint,
    pd_date text,
    team text,
    shift text,
    line text,
    opr1 te...

FDW仍然有问题。必须在遇到每个新的 FDW 错误后创建每个 FDW 服务器(我不记得全部)。循环这个过程,直到所有的 FDW 服务器错误都消失(这真的是应该如何进行无错误的 dababase 恢复......?)。下一个错误

pg_restore: [archiver (db)] could not execute query: ERROR:  server "myserver1"
does not exist
    Command was: CREATE FOREIGN TABLE t1 (
    fid bigint,
    pd_date text,
    team text,
    shift text,
    line text,
    opr1 te...

我已经物化了视图来缓存 plpython 函数结果。但是他们的一些逻辑被贬低了,不能轻易修复。

我想我的无错误恢复到此结束。必须取消-1单一交易模式。忽略的总错误从 55 减少到 6。看起来大多数对象都回来了。

有什么办法可以忽略物化视图刷新过程...

4

1 回答 1

0

错误消息看起来很奇怪 - 但如果理解得很好,PostgreSQL 会尝试在模式中恢复自定义数据类型public应该禁止的内容 - 请尝试仅以 SQL 格式转储模式并确保,因此没有直接修改的pg_catalogue方案。

应首先安装扩展 - 扩展安装有两个部分 1:将 rpm / 编译代码安装到数据库服务器,2:每个数据库的扩展注册。只有第二步应该通过备份来完成。

错误消息pg_restore: [archiver (db)] could not execute query: ERROR: server "myserver1" does not exist是干净的 - 可能是语句CREATE SERVER失败的地方 - 可能是由于服务器上缺少扩展。

于 2017-08-16T03:43:10.253 回答