Search code examples
pythondjangopostgresqlherokudjango-database

Migrating database from local development to Heroku-Django 1.8


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.


Solution

  • 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