I get my PostgreSQL database backup using the following command:
pg_dump --encoding utf8 "host=localhost port=5432
dbname=employee user=postgres" > C:\backup\employee.sql
Note: I tried both with and without --encoding parameter. Also tried to use many different file format for backup as: dump, tar, etc.
Then I try to restore database using the following command:
psql -e -h 127.0.0.1 -p 5432 -U postgres -d employee -f C:\backup\employee.sql
There are lots of lines on the console during restore process, but at the end of this log, the following error is shown:
psql:C:\backup\employee.sql:1: ERROR: syntax error at or near "ÿs" LINE 1: ÿs-ebSG:9loios3"s"des9",e3s{0LrT}0se"me"D13,mispRio""""aild{...
How can I fix it? I might convert backup file encoding via conv, but as I use Windows, I cannot used it.
Update:
Postgres version I am dumping from: PostgreSQL 12.6 on x86_64-pc-linux-gnu, compiled by Debian clang version 10.0.1 , 64-bit
Postgres version I am restoring to: PostgreSQL 11.12 (Debian 11.12-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
pg_dump version I am using: I have a look at the container to inspec pg_dump version, but cannot get the pg_dump folder.
employeeas shown by\lin both the source and target databases? 2) What is line output just before and after the error? If it where me I would drop the-eon the restore. That just generates lines that overshadow what you are really after, the errors.pg_dumpversion you are using?pg_dump -V. Also your original commands show you working in a Windows file system, yet the Postgres versions show them being on Linux. Please explain the discrepancy.