[英]issue with pg_restore s exit code when warnings are there
commands: 命令:
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
steps followed: 步骤如下:
add new tables to DB and took dump 将新表添加到DB并进行转储
delete the newly added tables 删除新添加的表
try restore with dump file 尝试使用转储文件还原
restore exited with code 1 but still tables are restore successfully. 使用代码1恢复退出但仍然可以成功恢复表。
error in pg_restore: pg_restore中的错误:
pg_restore: [archiver (db)] could not execute query: err-1: table "test1" does not exist pg_restore:[archiver(db)]无法执行查询:err-1:表“test1”不存在
Command was: DROP TABLE public.test1; 命令是:DROP TABLE public.test1;
WARNING: errors ignored on restore: 2 警告:恢复时忽略错误:2
Is this the expected behavior for dump/restore feature with tables add/delete steps? 这是带有表添加/删除步骤的转储/恢复功能的预期行为吗?
Using pg_restore
can be a pain in the neck if the tables of your target DB only partially overlap with the tables in the dump. 如果目标数据库的表只与转储中的表部分重叠,那么使用pg_restore
可能会pg_restore
感到痛苦。
Using the --clean
flag only partially solves the problem but you may still encounter errors for non-existing tables. 使用--clean
标志只能部分解决问题,但您可能仍会遇到不存在的表的错误。
In my opinion your best shot is to delete your target DB (or delete-cascade the target schema) and go with the restore. 在我看来,最好的方法是删除目标数据库(或删除级联目标模式)并继续执行还原。
A similar question you may want to look at: will pg_restore overwrite the existing tables? 你可能想看一个类似的问题: pg_restore会覆盖现有的表吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.