Piping pg_dump output
I was getting the following error when using pg_restore
to restore from a Postgres backup:
pg_restore: [custom archiver] could not read from input file: end of file
I’d created the dump file by piping the output of pg_dump
into a file:
pg_dump -Fc database > backup.dump
The problem was caused because I was piping the output of pg_dump
. This seems to work when dumping the database in SQL format, but not when dumping in the compressed binary format with the -Fc
flag.
The solution was to use the -f
file flag, rather then a pipe, to capture the output of pg_dump
pg_dump -Fc -f backup.dump database