Postgresql pg_还原输入文件似乎是文本格式转储文件。请使用psql
我有一个Ansible任务,它将在postgresql数据库中加载一个db转储文件Postgresql pg_还原输入文件似乎是文本格式转储文件。请使用psql,postgresql,ansible,psql,Postgresql,Ansible,Psql,我有一个Ansible任务,它将在postgresql数据库中加载一个db转储文件 name: Apply prod dump file become_user: postgres shell: "PGPASSWORD={{ db_password }} psql -h localhost -d {{ db_name }} -U {{ db_user }} -f {{ server_path }}/dump.sql" when: run_db_restore is defined a
name: Apply prod dump file
become_user: postgres
shell: "PGPASSWORD={{ db_password }} psql -h localhost -d {{ db_name }} -U {{ db_user }} -f {{ server_path }}/dump.sql"
when: run_db_restore is defined and run_db_restore
tags: django.restore
问题是转储文件包含CREATE ROLE和CREATE DATABASE节,我不想这样做,因为它将覆盖我用Ansible创建的进程,所以我想执行
pg\u还原--无所有者--仅数据
在sql文件上,因此我只能创建表和导入数据。问题是我该如何解决
psql-h localhost-d{{db_name}-U{{db_user}-f{{server_path}/dump.sql
所以我可以正确地导入数据库中的数据
此函数
pg\U restore--无所有者--仅数据-U admin-d数据库转储。sql
正在显示给我
pg_restore:[archiver]输入文件似乎是文本格式转储文件。请使用psql。
除非先编辑SQL文件,否则无法执行此操作,这是一项具有挑战性且容易出错的自动任务
我建议您更改过程,改用自定义格式转储。然后,您可以使用pg_restore
恢复它们,并且只恢复您需要的部件
由于您说转储中有用户,因此似乎是使用
pg_dumpall
创建的。如果你不想有用户在那里,就不要这样做。嘿,谢谢你的回答,我不是提供转储文件的人,但是我自己编辑了sql文件,所以现在一切都恢复正常了,这个命令--no psqlrc
也有帮助。