Mik*_*eck 60 postgresql pg-dump pg-restore
我在Linux服务器上有一个Postgres 8.4数据库,我使用以下命令转储:
pg_dump --format=c --exclude-table=log --file=/path/to/output my_db
Run Code Online (Sandbox Code Playgroud)
然后我将创建的文件ftp到我的本地Windows 7计算机,并尝试使用以下命令将文件恢复到我的本地Postgres 8.4实例:
pg_restore --create --exit-on-error --verbose c:\path\to\file
Run Code Online (Sandbox Code Playgroud)
restore命令生成大量输出,声称它创建了我的数据库,连接到它,然后按预期创建了所有其他表.但是,当我通过pgAdmin查看本地计算机上的数据库时,恢复的数据库根本不存在.
在尝试进行故障排除时,我尝试了以下命令:
pg_restore --create --exit-on-error --verbose --host=blahblah --username=no_one c:\path\to\file
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时,即使给出的主机和用户名是完全无意义的,我仍然可以从命令获得完全相同的输出而没有任何错误.
有没有人遇到这个或知道什么可以导致这个?
Mat*_*ood 109
您必须添加最初连接的有效数据库的名称,否则它只会将内容转储到STDOUT:
pg_restore --create --exit-on-error --verbose --dbname=postgres <backup_file>
Run Code Online (Sandbox Code Playgroud)
tgu*_*unr 10
这仍然令人困惑,我试图执行这个 --dbname 应该是我想要创建的数据库的事情。
pg_restore --create --exit-on-error --verbose --dbname=jiradb jiradb.tar
Run Code Online (Sandbox Code Playgroud)
错误的!!
它应该字面上是--dbname=postgres,--create 然后将从文件中的名称创建真正的数据库。就我而言,我从 tar 备份中恢复了
pg_restore --create --exit-on-error --verbose --dbname=postgres jiradb.tar
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22961 次 |
| 最近记录: |