We have been using 9.5 postgres.
And we use pgdump to get backup files from that database and then subsequently use it to restore on a 9.6 postgres.
We were unable to restore successfully. Usually the minor version upgrade does not mean backwards breaking.
I am wondering what's the issue causing us to be unable to successfully restore on a 9.6 database.
We need to do so just in case we need to restore from archived data backups.
I was facing the same error when upgrading from 9.3 to 9.6. The restore failed every time I tried but the dump was successful.
My solution to this problem was not to use the custom format! Instead I used the plain format. So I tried plain format with file extension sql, with utf8 encoding as user postgres. And obviously don't forget to include pre-data, data and post-data because otherwise your restore won't be complete. This works perfectly.
If your dump is ok, also try a full vacuum before the dump. If the vacuum is not ok, this might be your problem.
To Take Dump
pg_dump --username=postgres --format=c --file=e:/testdbdump.sql testdb
OR
pg_dump -U username databasename >>sqlfile.sql
To Restore
pg_restore --username=postgres --dbname=testdb<d:\sqlfile.sql
pg_restore --username=postgres --dbname=testdb <d:\sqlfile.sql
pg_restore --username=postgres --dbname=testdb <d:\testDBApr18.sql
pg_restore --username=postgres --dbname=testdb <c:\Backup\testdbDBApr18.sql
// PG DUMP & RESTORE THAT WORKS FOR ME
pg_dump -U postgres -h localhost --format=c testdb > db_dump_file.dump
pg_restore -U postgres -h localhost -v -d testdb db_dump_file.dump