PostgreSQL – Fix pg_dump and pg_restore Input File Does Not Appear to Be a Valid Archive

postgresql

I have used pg_dump on one machine and copied result file to another, where I tried to restore it. I believe schema is the same. However, I get:

pg_restore: [archiver] input file does not appear to be a valid archive

I have done following operations:

pg_dump -a -f db.txt dbname

and:

pg_restore -a -d dbname db.txt

What might be wrong?

Best Answer

You are dumping in plain SQL format which was designed to feed to psql. This is not recognized by pg_restore.

cat db.txt | psql dbname

Should do the trick

Related Topic