pg_dump and pg_restore: input file does not appear to be a valid archive
Solution 1:
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
Solution 2:
pg_dump
by default creates the sql commmands necessary to recreate the data. To recover it, you just need to invoke psql
(not pg_restore
) with the file as input . pg_restore
is only to be used for the binary (not default, and less usual not recommended) format of pg_dump
. Read the docs.
Update: The pg_dump
binary formats (-Fc
-Ft
) that are to be used with pg_restore
are ok, and offer some extra flexibility. But they are less standard (non SQL), less apt for importing from some tools (eg. a php frontend) or manipulate with a text editor, and a little less portable to other versions and even other databases. For backups, I'd stick with the default plain format. For other scenarios, the binary + pg_restore option can be equally or more apt.
The point to keep is that in Postgresql, in the typical scenario, the backup normally is done by pg_dump (plain) and the restore with the standard command line client (psql).