HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

Why is my pg_restore command not working?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whyworkingcommandnotpg_restore

Problem

Yesterday, I created backups of my various PostgreSQL databases using the following command:

pg_dump -Fc -d junk -h localhost -p 5434 -U postgres -W > z:\pg_dump\96_junk.dump


I created an individual backup for each database.

Today, I'm trying to restore them to an upgraded database server using the following command:

pg_restore -h localhost -p 5434 -U postgres -W -C -v z:\pg_dump\96_junk.dump


When I run pg_restore using the above it seems that the database was restored. The console screen displays a series of SQL statements and other messages I would expect to see for this database and, at the end, "PostreSQL database dump complete" is the output shown.

When I check the database, the database is not present. What am I doing wrong?

Employed versions info

-
Backups created with version 9.6.0

-
Attempting to restore using version 9.6.1

Solution

Try specifying the name of the DB to start in, using the -d or --dbname argument. This worked for me when I had the same problem. Note that it doesn't have to be the target DB:

pg_restore -h localhost -p 5434 -U postgres -d postgres -W -C -v z:\pg_dump\96_junk.dump

Code Snippets

pg_restore -h localhost -p 5434 -U postgres -d postgres -W -C -v z:\pg_dump\96_junk.dump

Context

StackExchange Database Administrators Q#157539, answer score: 7

Revisions (0)

No revisions yet.