Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is pg_restore returning successfully but not actually restoring my database?

I have a Postgres 8.4 database on a linux server that I have dumped using the following command:

pg_dump --format=c --exclude-table=log --file=/path/to/output my_db 

I then ftp the created file to my local Windows 7 machine and attempt to restore the file to my local Postgres 8.4 instance using the following command:

pg_restore --create --exit-on-error --verbose c:\path\to\file 

The restore command generates plenty of output claiming it created my database, connected to it, and then created all the other tables as expected. However, when I view the databases on my local machine through pgAdmin the restored database doesn't exist at all.

In an attempt to troubleshoot I tried the following command:

pg_restore --create --exit-on-error --verbose --host=blahblah --username=no_one c:\path\to\file 

When I run this command even though the host and username given are complete nonsense I still get the exact same output from the command without any errors.

Has anyone run into this before or know what could by causing this?

like image 734
Mike Deck Avatar asked May 05 '11 16:05

Mike Deck


People also ask

How do I check my Postgres backup status?

To know the status of PostgreSQL backup, check the arcserve_postgresql_backup_${DATE}. log file. This log file gets created under the directory, which is set by the user. For more information about configuring the directory, refer to the postgresql_settings file.


1 Answers

You have to add the name of a valid database to initially connect to or it will just dump the contents to STDOUT:

pg_restore --create --exit-on-error --verbose --dbname=postgres <backup_file> 
like image 184
Matthew Wood Avatar answered Oct 21 '22 12:10

Matthew Wood