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

Viewed 14149

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.

3 Answers

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 

Just experienced this problem, I wasn't able to get it to work with the answers provided here, but changing the extension of the output file to .psql managed to fix it for some reason

pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.psql
Related