简体   繁体   中英

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?

您必须添加有效数据库的名称以进行初始连接,否则它只会将内容转储到 STDOUT:

pg_restore --create --exit-on-error --verbose --dbname=postgres <backup_file>

This is still confusing, I attempted to execute this thing that the --dbname should be the db I want to create.

pg_restore --create --exit-on-error --verbose --dbname=jiradb jiradb.tar

WRONG!!

It should literally be --dbname=postgres, the --create then will create the real db from the name in the file. In my case, I restored from a tar backup with

pg_restore --create --exit-on-error --verbose --dbname=postgres jiradb.tar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM