When trying to restore a data-only pg_dump from postgres, I got this error about a billion times:
invalid command \N invalid command \N invalid command \N
The problem here is not the invalid commands. It’s the fact that the real error is reported somewhere far up in your terminal history, long hidden by the trillions of lines of other output. So try it again, this time piping stdout and stderr to a file, so that you can see what the original error is. Like this:
psql my_database < dump.sql &> db_restoration_output.txt
The advice on how to output stdout and stderr to a file comes from Stack Overflow
Now, you can search in the file to find what the real error is.