R
Railwayβ€’16mo ago
anubhav_

Migrate Postgres from Heroku to Railway

I'm trying to migrate my postgres database from Heroku to Railway. I already have a dump file from Heroku. I'm following this guide to restore the database: https://blog.railway.app/p/postgre-backup#restoring-your-database-backup However, when I run the command:
pg_restore -U <USER> -h <HOST> -p <PORT> -W -F t -d <DATABASE> latest.dump
pg_restore -U <USER> -h <HOST> -p <PORT> -W -F t -d <DATABASE> latest.dump
I get the following error:
pg_restore: error: corrupt tar header found in PGDMP (expected 0, computed 19448) file position 512
pg_restore: error: corrupt tar header found in PGDMP (expected 0, computed 19448) file position 512
Pls note: - I've tried running this command on both Windows and Ubuntu, still I get the same error - The dump file was created before Heroku removed the free tier. So now, I can't create a new dump file since heroku has deleted my data
Railway Blog
How to Backup and Restore Your Postgres Database
In this post, we will go over the process of backing up and restoring your Postgres database hosted on Railway.
Solution:
it looks like heroku has provided a pg_restore command that will work with it's dump files https://devcenter.heroku.com/articles/heroku-postgres-import-export just substitute for your database credentials from railway...
Jump to solution
11 Replies
Percy
Percyβ€’16mo ago
Project ID: 3bf60097-8588-44db-8386-146da476727f
anubhav_
anubhav_β€’16mo ago
3bf60097-8588-44db-8386-146da476727f
Brody
Brodyβ€’16mo ago
how do you know the dump file you have is not corrupted?
anubhav_
anubhav_β€’16mo ago
I don't...so this means that the file is corrupted? Is there any possibility to migrate then? I actually have a dump of all my projects which I had on Heroku previously. I tried running the command on those different dump files as well. But they also show the same error...
Brody
Brodyβ€’16mo ago
i mean I'd look into ways to check if that file is corrupt. but are you using the pg_restore tool that was released at the same time the pg_dump tool you used was released?
anubhav_
anubhav_β€’16mo ago
I didn't use pg_dump for creating the dump, I directly used the heroku command, as said here: https://devcenter.heroku.com/articles/heroku-postgres-import-export#capture-and-download-backup-with-pgbackups
heroku pg:backups:capture --app example-app
heroku pg:backups:download --app example-app
heroku pg:backups:capture --app example-app
heroku pg:backups:download --app example-app
Brody
Brodyβ€’16mo ago
are you using the correct flags on pg_restore to restore the type of dump file you took? oh yeah interesting, what format does that provide the dump in? I highly doubt your dump files are corrupted, they're just not in the format that pg_restore expects
anubhav_
anubhav_β€’16mo ago
it exports in .dump format, so my file name is like: latest.dump
Solution
Brody
Brodyβ€’16mo ago
it looks like heroku has provided a pg_restore command that will work with it's dump files https://devcenter.heroku.com/articles/heroku-postgres-import-export just substitute for your database credentials from railway
anubhav_
anubhav_β€’16mo ago
It worked, Thank you so much for your time and help!! πŸ˜€
Brody
Brodyβ€’16mo ago
glad it worked! πŸ™‚
Want results from more Discord servers?
Add your server