我曾经pg_dump -Fc ...
以压缩格式转储我的数据库。
问题是当我pg_restore --create -d [some_auxiliary_db]
用来取回数据库时。即使在 pg_dump / pg_restore 文档页面中说:
-C --create
在恢复之前创建数据库。如果还指定了 --clean,则在连接到它之前删除并重新创建目标数据库。使用此选项时,以 -d 命名的数据库仅用于发出初始 DROP DATABASE 和 CREATE DATABASE 命令。所有数据都恢复到存档中出现的数据库名称中。
https://www.postgresql.org/docs/9.4/static/app-pgrestore.html
https://www.postgresql.org/docs/9.4/static/app-pgdump.html
此外,对于为我的转储数据库创建的扩展,它们也丢失了。
然而,使用纯文本 .sql 转储pg_dump
包含这些信息。
有没有一种方法或选项组合可以让我以存档格式转储数据库所有权数据和扩展?
我的 pg_dump 命令:
pg_dump -Fc -Z1 -U postgres -f [targetdb.dump] [targetdb]
我的 pg_restore 命令:
pg_restore --create --clean -j 6 -U postgres -d [auxiliarydb] -n public [targetdb.dump]