python - 无法在heroku上恢复postgres转储
问题描述
我正在使用此命令在本地创建转储,
PGPASSWORD=admin pg_dump -h 127.0.0.1 -p 5432 -U postgres --no-owner --no-acl -f database.dump
并且我的已成功创建。
然后将此转储上传到保管箱并通过此链接http://www.dropbox.com/s/rsqeiuqzusejz5x/database.dump?dl=1
通知将其公开我已更改https
为http
和(dl = 1dl=0
以dl=1
使其可下载)
然后在我的终端上我正在运行这个命令heroku pg:backups:restore "http://www.dropbox.com/s/38prh2y7pdwhqqj/database.dump?dl=1" --confirm tranquil-anchorage-39635
但我收到了这个错误
! An error occurred and the backup did not finish.
!
! pg_restore: error: did not find magic string in file header
! waiting for restore to complete
! pg_restore finished with errors
! waiting for download to complete
! download finished successfully
!
! Run heroku pg:backups:info r010 for more details.
我已经尝试了所有官方文档和各种答案,但似乎没有任何效果。
解决方案
在进行进一步研究时,我发现pg_restore
在恢复转储文件时该命令需要在创建转储文件时必须提及的某种格式。这就是出现错误的原因 pg_restore: error: did not find magic string in file header
。
pg_dump -h <localhost> -p <port> -U <username> --format=c <database_name> > daman.dump
运行此命令后,您将被提示输入用户密码。
注意--format=c
上面的命令。这将创建一个可以通过 恢复的格式的转储文件pg_restore
,我还应该提到,以这种方式创建的转储文件对于记事本或 vscode 等文本编辑器不可读,这与--format=c
不使用的情况不同。
推荐阅读
- angularjs - 未捕获的类型错误:无法使用 Angular 的 http.get 读取未定义的属性“get”
- javascript - Javascript:仅在不重复的情况下合并两个对象数组(基于指定的对象键)
- c - 当我强制退出服务器(输入 clt + c)时,有什么办法可以做到这一点,客户端也会同时终止?
- autoscroll - 如何在我的页面中自动向下滚动?
- r - R:对于缓慢的双 sapply,我该怎么办?
- google-maps - 我可以使用相同的参数多次调用 google.maps.event.addListenerOnce 吗?
- java - 从适配器向活动添加功能时遇到问题
- matlab - 找出所有等于其数字的阶乘之和的数字
- macos - llvm-otool (mac) 的源代码在哪里?
- angular - 使用 Observable 或 Promise 在 Angular 6 中转换管道