Reputation: 7458
I'm currently trying to restore a database from a backup created by pg_dump (which is small ~100mb) from a tar file.
However attempting to restore with
pg_restore -U postgres -f "example.tar"
just keeps hanging and never seems to work.
What's the best way to try to diagnose and fix the issue?
Upvotes: 5
Views: 4299
Reputation: 165110
It's waiting for input on stdin.
-f
specifies an output file, not an input file. With no input it's waiting for input on stdin. If you type ctrl-d
to end input it will say something like pg_restore: error: input file is too short (read 0, expected 5)
.
The proper invocation is...
pg_restore --dbname=DatabaseName -Upostgres --format=tar example.tar
--dbname
is the name of the database to restore to. If it does not exist, add --create
to tell pg_restore
to create it.
The --format=tar
is not strictly necessary, pg_restore
can guess the file type, but why risk it?
See the pg_restore docs.
Upvotes: 9