1

im trying to make a dump of all tables and schemes of an postgres docker container with the following command:

docker exec -i 3d7de2fb2d7a -u admin pg_dumpall > dumptest.sql

this creates a dumptest.sql file which should contain everything.

The restore process looks like this:+

 cat .\dumptest_neu.sql | docker exec -i bec713662fb6 psql -U admin

The Problem: After I have executed the command I get the following error message:

invalid command \":
ERROR:  syntax error at or near "OCI"
LINE 1: OCI runtime exec failed: exec failed: container_linux.go:349...
        ^

After doing some research, I found out that I need to add a /bin/bash to the command:

cat .\dumptest_neu.sql | docker exec -i 7f75d4c0c9e3 /bin/bash psql -U admin

And then I get the following message:

/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'

Please help me im just trying to make a dump of everything in this postgres container.

This does not help beacause I have to dump all tables at once.

Nico
  • 95
  • 1
  • 2
  • 7
  • `psql` looks to me like a Perl program (because of the `my` declaration. What is the reason that you execute it via bash? – user1934428 Nov 30 '21 at 08:59
  • In our company it is not allowed to use tools like dbeaver or dbvisualizer. Besides, it should be possible to do it this way. – Nico Nov 30 '21 at 09:10
  • You didn't get my question right: From what you posted, `psql` is not a bash program, so writing `/bin/bash psql` looks insane to me. This has nothing to do with what tools you can or can not use. BTW, you didn't even post the code of the program which causes the error messages; how can you expect a diagnosis for this? – user1934428 Nov 30 '21 at 09:12
  • You're right, I misunderstood your question. But even if I leave it out it doesn't work (see first issue). But the program code is not important because it is a dump with data and the postgres container is new and empty. Data --> Postgres container – Nico Nov 30 '21 at 09:29
  • Well, what is the #! line of `psql`? – user1934428 Nov 30 '21 at 09:34
  • The file you dumped is not the file you are trying to restore. – jjanes Nov 30 '21 at 19:25

0 Answers0