[英]how to restore a postgresql database to the exact same state?
I am trying to 我在尝试着
pg_dump
), pg_dump
), These can happen over many/different days. 这些可能会发生很多天/不同天。 Also I am in a multi-user environment where I am not DB admin.
另外,我处于不是DB管理员的多用户环境中。 In particular, I cannot create new DB.
特别是,我无法创建新的数据库。
However, when I restore db using 但是,当我使用还原数据库时
gunzip -c dump_file.gz | psql my_db
changes in step 2 above remain. 上面步骤2中的更改仍然存在。
For example, if I make a copy of a table: 例如,如果我复制一张表:
create table foo1 as (select * from foo);
and then restore, the copied table foo1
remains there. 然后还原,复制的表
foo1
保留在那里。
Could some explain how can I restore to the exact same state as if step 2 never happened? 有人可以解释一下如何恢复到步骤2从未发生过的完全相同的状态吗?
-- Update -- -更新-
Following the comments @a_horse_with_no_name, I tried to to use 在评论@a_horse_with_no_name之后,我尝试使用
DROP OWNED BY my_db_user
to drop all my objects before restore, but I got an error associated with an extension that I cannot control, and my tables remain intact. 在还原之前删除所有对象,但是出现了与我无法控制的扩展相关的错误,并且我的表保持不变。
ERROR: cannot drop sequence bg_gid_seq because extension postgis_tiger_geocoder requires it
HINT: You can drop extension postgis_tiger_geocoder instead.
Any suggestions? 有什么建议么?
You have to remove everything that's there by dropping and recreating the database or something like that. 您必须通过删除并重新创建数据库或类似方法来删除其中的所有内容。 pg_dump basically just makes an SQL script that, when applied, will ensure all the tables, stored procs, etc. exist and have their data.
pg_dump基本上只是制作一个SQL脚本,该脚本在应用时将确保所有表,存储的proc等都存在并具有其数据。 It doesn't remove anything.
它不会删除任何内容。
您可以使用PostgreSQL模式 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.