因此,我定期使用pgadmin4备份和还原数据库和架构。我想使用批处理文件使用pg_dump和pg_restore命令来执行此操作。但是,我总是无法成功实现这一目标,可以寻求帮助。我尝试转储一个模式(带有数据)的方式如下:
pg_dump -U postgres -F c -d database -n schema > mw2
然后,我尝试使用pg_restore还原它:
pg_restore -U postgres -d otherdatabase -n schema mw2
首先,我尝试使用.dump代替tar,但是结果保持不变;这是我数据库中的空模式。
或以下错误消息:
pg_restore: [archiver] input file does not appear to be a valid archive
https://www.postgresql.org/docs/current/static/app-pgrestore.html
--format = format指定存档的格式。无需指定格式,因为pg_restore将自动确定格式。如果指定,则可以是以下之一:
自定义,目录和tar
https://www.postgresql.org/docs/current/static/app-pgdump.html
--format =格式
选择输出格式。格式可以是以下之一:
p plain输出纯文本SQL脚本文件(默认)。
其他是自定义,目录和tar
简而言之,您使用的是defualt普通格式,该格式旨在用于psql
,而不是pg_restore
。因此,您可以指定其他格式pg_dump
或将您的文件用作
psql -f mw2.tar
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句