以`directory`格式从PostgreSQL备份中删除模式的命令

I make a database backup using a command like (-Fd meaning "directory" format):

pg_dump -U postgres -Fd -j 8 -f testdb.dir testdb

我的数据库包含许多包含个人数据的架构。有时我可能需要从备份中删除一个架构。恢复和重新转储不是可行的解决方案(备份太多)。

So ideally I would need a command like command --remove-schema=user123 testdb.dir. That would just remove an appropriate 1234.dat.gz file and perhaps update toc.dat inside testdb.dir.

PS: I know I can list contents with pg_restore -l, but haven't found docs describing format of the output file. I don't want to guess what is what and risk data loss.

最佳答案

There is no way to do it. You can try to remove it by grep -p but it is very complicate as for me. Probably is easier to remove schema after restoring

评论