1

My PowerShell current directory is the backup directory/folder. I use pg_dump -h localhost -p 5432 -U postgres -d postgres -t emp > empbackup.sql to backup one specific table. I aslo use pg_dump -h localhost -p 5432 -U postgres -d postgres -t emp > empbackup.dump. Now I want to restore this table to the database. emp table is no foreign key, primary key, totally isolated table. I tried serval ways. All failed. related question: PostgreSQL - restoring one table from database dump

pg_restore -t emp -d postgres empbackup.sql

Error pg_restore: error: input file does not appear to be a valid archive

psql -U postgres -d postgres  -f empbackup.sql

Error --psql:empbackup.sql:1: ERROR: syntax error at or near "ÿ_"
--LINE 1: ÿ_-

pg_restore --host localhost --port 5432 --username postgres -d postgres  -t     public.emp  --verbose "C:\Users\JIAN HE\Desktop\pg\empbackup.sql"

Error --pg_restore: error: input file does not appear to be a valid archive

pg_restore -t emp -d postgresql empbackup.dump

Error pg_restore: error: input file does not appear to be a valid archive

1
  • Nope. I don't know how to compress... Commented Sep 23, 2021 at 14:15

1 Answer 1

1

The y with the dots is a misinterpretation of a UTF byte order marker (BOM)

In my hands, psql -f file on powershell doesn't know how to deal with these, but on a pipe it does (Or they just don't get written on a pipe)

type empbackup.sql | psql -U postgres -d postgres
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.