This won't work well because both programs are trying to read from the same terminal input stream at the same time. Some of them get some parts of each of what you type, so passwords are mangled.
Use a ~/.pgpass
file to supply the passwords, or use the PGPASSWORD
environment variable:
PGPASSWORD='pw_for_dump' pg_dump .... | PGPASSWORD='pw_for_restore' pg_restore ...
The .pgpass
file is preferable.