The pg_dump -Fd mydb -f mydb.dump
command creates a mydb.dump
directory with a toc.dat
file. The pg_dump
man page mentions that pg_restore
is able to read this file, but after skimming its man page and stumbling upon this PostgreSQL mailing list thread, I get this cryptic error:
$ pg_restore -l mydb.dump/toc.dat
pg_restore: error: expected format (1) differs from format found in file (3)
Best Answer
TL;DR
pg_restore
expects the a directory when reading from directory dumps:So, in the case above, it is
pg_restore -l mydb.dump
.After a more careful reading of the
pg_restore
man page, I found the-F
option:So I tried
pg_restore -l mydb.dump/toc.dat -Fd
next; the result:Then
pg_restore -l mydb.dump -Fd
, which worked, so I gave it try deleting-Fd
from the end, which also did.update: Could have avoided this experimentation if I had actually paid attention to the man page (emphasis mine):