Cant pg_restore on Heroku: “could not read from input file: end of file”

旧时模样 提交于 2020-01-23 06:28:09

问题


I am trying to copy my local PostgreSQL DB to Heroku app with pg_dump / pg_restore utils. Doing according to Heroku's official guide: https://devcenter.heroku.com/articles/heroku-postgres-import-export

So, i've done the dump:
pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump

Then i've uploaded it on a reachable across the web server (and its really reachable, i've checked it downloading the file with wget and pg_restoreing it - works fine).

Then i've tried to restore in on Heroku and no luck:

kulver@kvb:~/projects/gop/gop_flask$ heroku pg:backups restore 'MY_URL_HERE' postgresql-corrugated-15763
r010 ---restore---> DATABASE
An error occurred and your backup did not finish.

Please run `heroku pg:backups info r010` for details.

Here are the details:

kulver@kvb:~/projects/gop/gop_flask$ heroku pg:backups info r010
=== Backup info: r010

Database:    BACKUP
Started:     2016-03-26 20:15:32 +0000
Finished:    2016-03-26 20:15:32 +0000
Status:      Failed
Type:        Manual
Backup Size: 23.9MB
=== Backup Logs
... a bunch of logs here ...
2016-03-26 20:15:32 +0000: pg_restore: processing data for table "cards"
2016-03-26 20:15:32 +0000: waiting for restore to complete
2016-03-26 20:15:32 +0000: pg_restore: [custom archiver] could not read from input file: end of file
2016-03-26 20:15:32 +0000: restore done
2016-03-26 20:15:32 +0000: waiting for download to complete
2016-03-26 20:15:32 +0000: download done

I've tried to remake the dump file, reload it - same error. What's wrong? Why can i download it and restore from it on the just created DB, but not on Heroku?

Thank you for any advise.


回答1:


I failed to load the dump in the exact described above way, BUT i've come to another solution which worked fine for me:

Make the dump in simple SQL format:
pg_dump --no-owner mydb > mydb.dump

You may need to switch to the user who has rights to access your DB, postgres for example. So, sudo su postgres and then make the dump.

And then load it with psql tool:
user@pc:~/path/to/your/dump$ heroku pg:psql < mydb.dump




回答2:


There appears to be an issue with piping to the file. I created the dump using the -f command to specify the file and that solved my issue.

pg_dump -f mydb.dump -Fc --no-acl -no-owner -h localhost -U myUser --schema=public myDatabase 


来源:https://stackoverflow.com/questions/36240600/cant-pg-restore-on-heroku-could-not-read-from-input-file-end-of-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!