After establishing a database using heroku addons:create heroku-postgresql:hobby-dev
, I tried to migrate my local database to heroku database. So I first ran
heroku python manage.py migrate
. After that I created a dump file of my local database using pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump
. I uploaded my mydb.dump
file to dropbox and then used the following command to load the dump to my heroku database
heroku pg:backups restore'https://www.dropbox.com/s/xkc8jhav70hgqfd/mydb.dump?' HEROKU_POSTGRESQL_COLOR_URL
But, that throws the following error -
r004 ---restore---> HEROKU_POSTGRESQL_PURPLE
[0KRunning... 0.00B..
[0KAn error occurred and your backup did not finish.
Please run `heroku pg:backups info r004` for details.
And on running heroku pg:backups info r004
I get -
Database: BACKUP
Started: 2015-06-25 18:19:37 +0000
Finished: 2015-06-25 18:19:38 +0000
Status: Failed
Type: Manual
Backup Size: 0.00B
=== Backup Logs
2015-06-25 18:19:38 +0000: waiting for restore to complete
2015-06-25 18:19:38 +0000: pg_restore: [archiver] did not find magic string in file header
2015-06-25 18:19:38 +0000: restore done
2015-06-25 18:19:38 +0000: waiting for download to complete
2015-06-25 18:19:38 +0000: download done
There is not much information on this error online and I can't figure out what the problem is.
If the database is small and you feel lucky this might do it
pg_dump --no-acl --no-owner -h localhost -U myuser myd | heroku pg:psql
I've had this error too and my solution was a little different. The problem was related to the format used. I needed to use --format=c when dumping the db.
To solve it I dumped the db again using --format=c
pg_dump --no-acl --no-owner --format=c database_name > db.dump
Then importing it to my heroku app
heroku pg:backups restore 'url_for_db.dump' DATABASE_URL
Hope this helps someone in the future!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With