According to documentation, this works like so (OS agnostic):
psql dbname < infile
However, this gave the following error:
ERROR: missing data for ...
However, the documentation for psql gives an alternative way to read commands from a file:
The -f switch.
- Read commands from the file filename, rather than standard input.
This option can be repeated and combined in any order with
the -c option. When either
-c or -f is
specified, psql does not
read commands from standard input; instead it terminates
after processing all the -c and
-f options in sequence. Except for
that, this option is largely equivalent to the meta-command
If filename is - (hyphen), then standard input is read until an EOF indication or \q meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if -n had been specified).
Using this option is subtly different from writing psql < filename. In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.
What this doesn't tell you, is that on Windows, CMD.exe apparently somehow tries to interpret the file it reads. And by doing so, it destroyed data in the dump so that COPY was unable to understand it anymore. So the last sentence of the statement above is just theory on Windows.
Long story short, with psql -f all went fine - and don't use I/O redirection with psql on Windows!