[英]Unable to restore psql DB in docker, after a pg_dumpall [on hold]
I have a docker which contain a postgresql database. 我有一个包含postgresql数据库的码头工人。
I want to try my backup from zabbix with a restauration to a new contener. 我想尝试从zabbix备份并恢复到新的竞争者。
These 2 conteners have same IP, same info, just the the port changing. 这两个竞争者具有相同的IP,相同的信息,只是端口在变化。
With this command I create my dumpall : 使用此命令,我创建了dumpall:
docker exec number_of_contener1 pg_dumpall -c --username=username > /tmp/dump.sql
And with this one I try to restore, to the other contener (no pg_restore since it's a text file) : 然后,我尝试将其还原到另一个竞争者(因为它是文本文件,所以没有pg_restore):
docker exec number_of_contener2 psql --username=username -d name_of_database < /tmp/dump.sql
I have no error, but I don't see anything in my database with \\dt . 我没有错误,但是使用\\ dt在数据库中什么也看不到。
My dump.sql is not empty, but my /var/log/postgresql on my contener is. 我的dump.sql不是空的,但是我的容器中的/ var / log / postgresql是。
What am I doing it wrong? 我做错了什么? (I'm not a linux expert). (我不是Linux专家)。
Thank you by advance 提前谢谢你
You need to use interactive
mode to read a file from your local machine: 您需要使用interactive
模式从本地计算机读取文件:
docker exec -i number_of_contener2 psql --username=username -d name_of_database < /tmp/dump.sql
Note that using >
and <
cause Docker to write and read data to/from your host OS, not the OS running in the container. 请注意,使用>
和<
会导致Docker向您的主机OS(而不是容器中运行的OS)读写数据。 If you want psql
to read data in from a file (basically, interactively), you need to pass in the -i
or --interactive
flag. 如果希望psql
从文件中读取数据(基本上是交互式地),则需要传递-i
或--interactive
标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.