【问题标题】:issue with pg_restore s exit code when warnings are there出现警告时 pg_restore 的退出代码问题
【发布时间】:2015-03-17 09:52:57
【问题描述】:

命令:

bin/pg_dump -b -o -Fc -Z 0 -p 5333 -U user template1 -f db.dump
bin/pg_restore -c  -h localhost -p 5333 -U user -d template1 db.dump 

接下来的步骤:

  1. 向数据库添加新表并进行转储

  2. 删除新添加的表

  3. 尝试使用转储文件恢复

  4. 恢复以代码 1 退出,但表仍成功恢复。

pg_restore 中的错误:
pg_restore:[archiver (db)] 无法执行查询:err-1:表“test1”不存在
命令是:DROP TABLE public.test1;
警告:还原时忽略错误:2

这是带有表添加/删除步骤的转储/恢复功能的预期行为吗?

【问题讨论】:

  • 尝试从pg_restore 中删除-c (--clean) 选项。如果表不存在,那么-c 产生的尝试DROP TABLE 将导致错误。

标签: postgresql pg-restore


【解决方案1】:

如果目标数据库的表仅与转储中的表部分重叠,则使用 pg_restore 可能会让人头疼。

使用--clean 标志只能部分解决问题,但您仍然可能会遇到不存在的表的错误。

在我看来,最好的办法是删除目标数据库(或删除级联目标架构)并进行恢复。

你可能想看看类似的问题:will pg_restore overwrite the existing tables?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-04
    • 2013-09-28
    • 1970-01-01
    • 2011-08-03
    相关资源
    最近更新 更多