#pg_restore not working corrupt tar header found

43 messages · Page 1 of 1 (latest)

wide parcel
#

Trying to migrate from heroku postgres over to railway. The guide (https://blog.railway.app/p/postgre-backup) recommends using pg_dump and pg_restore. Once I had my latest.dump file from heroku I tried importing with pg_restore. It fails with pg_restore: error: corrupt tar header found in PGDMP (expected 0, computed 19329) file position 512

Found this StackOverflow answer to a similar problem. It recommended making sure pg_dump and pg_restore have the same version. Upgraded my local pg installation to 14.5 (the version heroku is running) but the error remains.

Any help appreciated.

Railway Blog

In this post, we will go over the process of backing up and restoring your Postgres database hosted on Railway.

grand stag
fiery harness
#

having the same issue right now

grand stag
#

yeah, looking

grand stag
wide parcel
fiery harness
#

I ran these commands in the Heroku CLI: heroku pg:backups:capture --app example-app
heroku pg:backups:download --app example-app

devout vapor
#

Any chance y'all can run pg_dump on the heroku db?

#

Ah, looks like that's what Heroku runs internally.

#

Could you share the pg_restore command you ran?

fiery harness
#

I tried these:

#

pg_restore -U postgres -h containers-us-west-16.railway.app -p 7241 -W -F t -d railway latest.dump

#

railway run pg_restore -U postgres -h containers-us-west-16.railway.app -p 7241 -W -F t -d railway latest.dump

#

both giving that error

devout vapor
#

Could you try the command Heroku runs when they restore? pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump

#

Seems like they run a pg_dump with the custom format option.

wide parcel
fiery harness
wide parcel
fiery harness
#

how do you connect to the heroku database?

devout vapor
fiery harness
#

Thanks. One last question, when running the restore command do I need 'railway run' before the command?

devout vapor
#

Not in this case as you're manually pasting the values.

#

railway run is used when you need to inject the environment variable values.

fiery harness
#

ok, so just pg_restore -U postgres -h containers-us-west-16.railway.app -p 7241 -W -F t -d railway latest.dump in the terminal?

devout vapor
#

Yes.

fiery harness
#

perfect, thanks for the help

wide parcel
fiery harness
wide parcel
#

It's a 2 step process. Seems heroku uses their own format. First pg_dump then pg_restore

wide parcel
fiery harness
#

legend

wide parcel
#

Then pg_restore -U $USER -h $HOST -p $PORT -W -F t -d $DATABASE latest.dump with the railway credentials.

#

fp, it'd would be cool to update the heroku migration article with the fact that heroku uses a weird dump format. Lots of people moving over lately

devout vapor
#

cc @shadow cobalt if you want to take this or I can do it when I wake up! 😄

shadow cobalt
#

I can put it in my to-dos for today!

drowsy crag
#

Got same issue here, can help?

drowsy crag
shadow cobalt
drowsy crag
shadow cobalt
#

Making an exception for you 🙂