【问题标题】:Unable to restore database backup on Postgresql-10.0无法在 Postgresql-10.0 上恢复数据库备份
【发布时间】:2018-05-03 11:34:02
【问题描述】:

我在我的 Linux 机器(RHEL 7.4)上使用 postgresql-9.4(端口 5432)和 postgresql-10.0(端口 5433)。 Postgresql-9.4 使用 yum 存储库安装,Postgresql-10.0 使用不同分区中的源安装。

我已经使用它的 pg_dump 在 Postgresql-9.4 上备份了 db (dtbase.backup),并尝试使用它的 pg_restore 在 Postgresql-10.0 上恢复它。

执行此操作时,出现以下错误:

pg_restore: [archiver] unsupported version (1.13) in file header

我检查了不同的论坛,但无法找到解决方案。任何帮助将不胜感激。

【问题讨论】:

  • /home/post10/bin/pg_restore 是 Postgresql-10 的 pg_restore 的默认路径
  • /home/post10/bin/pg_restore -l /tmp/dtbase.backup | head -n 20 给我同样的错误。
  • 尝试使用 oder pg_dump 获取 dum?..
  • 旧 pg_dump 工作正常。将数据库转储为 dtbase.backup,pg_dump 为 9.4
  • 所以/home/post10/bin/pg_dump/home/post10/bin/pg_restore 创建了一个过于高级的备份?.. 嗯...没有想法

标签: linux postgresql pg-restore


【解决方案1】:

你必须将你的 PostgreSQL v10 升级到 10.3,这样你才能提交 b8a2908f0ac735da68d49be2bce2d523e363f67b:

Avoid using unsafe search_path settings during dump and restore.

Historically, pg_dump has "set search_path = foo, pg_catalog" when
dumping an object in schema "foo", and has also caused that setting
to be used while restoring the object.  This is problematic because
functions and operators in schema "foo" could capture references meant
to refer to pg_catalog entries, both in the queries issued by pg_dump
and those issued during the subsequent restore run.  That could
result in dump/restore misbehavior, or in privilege escalation if a
nefarious user installs trojan-horse functions or operators.

This patch changes pg_dump so that it does not change the search_path
dynamically.  The emitted restore script sets the search_path to what
was used at dump time, and then leaves it alone thereafter.  Created
objects are placed in the correct schema, regardless of the active
search_path, by dint of schema-qualifying their names in the CREATE
commands, as well as in subsequent ALTER and ALTER-like commands.

Since this change requires a change in the behavior of pg_restore
when processing an archive file made according to this new convention,
bump the archive file version number; old versions of pg_restore will
therefore refuse to process files made with new versions of pg_dump.

Security: CVE-2018-1058

您的 9.4 安装已使用存档格式 1.13,而您的 v10 安装尚不理解。

此外,您应该始终使用更高 PostgreSQL 版本的pg_dump 来升级数据库。

【讨论】:

  • 那么,如果我使用源安装它,我该如何升级它?我需要先卸载它吗?我是新手。
  • 您可以卸载 10.0 并替换它,也可以将 10.3 安装到其他位置 (configure --prefix)。
  • 我没有升级就解决了。我再次使用 10.0 而不是 9.4 的 pg_dump 进行备份,这次 pg_restore 工作
  • 当然。您仍然应该升级,因为 10.0 有缺陷且不安全。
猜你喜欢
  • 2014-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-10
  • 2013-09-03
  • 2013-10-15
相关资源
最近更新 更多