use*_*363 6 postgresql restore
我们要恢复到现有的 9.3 pg 数据库。我们最终做的是:
1) delete the database and recreate again,
2) use pg_restore to restore.
3) reboot the ubuntu server to allow rails app to pick up the new database.
Run Code Online (Sandbox Code Playgroud)
我们尝试了以下 pg_restore 命令,但它没有恢复到现有数据库:
$pg_restore --dbname=existing_database --verbose /home/myname/dbbackup.backup
Run Code Online (Sandbox Code Playgroud)
pg_restore 之后,existing_database 没有变化。是否有命令可以恢复到现有的 pg 数据库而无需像我们那样先删除它?我们必须使用命令行。非常感谢。
您显示的命令看起来不错。
pg_restore -d target_database /path/to/the/backup.dbbackup
Run Code Online (Sandbox Code Playgroud)
猜测是在恢复过程中出现了错误,但您没有看到它们。很可能您使用的用户 ID 没有执行还原的正确权限。
如果您确定目标数据库中没有任何值的数据(将被以下命令删除),请尝试:
sudo -u postgres pg_restore --create --clean -d postgres /path/to/dbbackup.sql
Run Code Online (Sandbox Code Playgroud)
如果您有问题,请将输出发布到您的问题的编辑中,然后在此处发表评论。
另外:你不是需要重新启动服务器。您最多应该重新启动 Rails 应用程序。通常这意味着重新启动 Apache,但这在一定程度上取决于您运行 Rails 的方式。完全没有必要重新启动整个服务器。
归档时间: |
|
查看次数: |
23994 次 |
最近记录: |