christo
christo

Reputation: 127

Migrate PostgreSQL local db to Heroku on Windows 7

Noob to Heroku and Postgres, and using Windows 7 and git bash to try to port my local Django postgres 9.4 database to Heroku. At the moment I'm stuck with a server 500 error on my heroku app. But the Django site and database work fine on my local environment (ie. my laptop).

I've tried multiple permutations of what appear to be the main methods to to migrate the local database, such as the following:

1. Reset followed by pg:push

$ heroku pg:reset HEROKU_POSTGRESQL_BLACK
$ PGUSER=MyUsername PGPASSWORD=MyPassword heroku pg:push localdb HEROKU_POSTGRESQL_BLACK -a MyAppname

Errors:

pg_dump: blah blah blah

:

pg_restore: [archiver] did not find magic string in header

pg_dump: [custom archiver] could not write to output file: Invalid argument

And $ heroku pg:info showed 0 tables

2. Dump db to SQL and try to push that

$ pg_dump -U MyUsername -d localdb --no-owner --no-acl -f backup.sql
$ heroku pg:psql --app MyAppname < backup.sql

(btw, the backup.sql file was populated and looked fine)

Errors:

Nothing happened, just a new line in bash.

And $ heroku pg:info showed 0 tables

3. Dump db, copy to Dropbox and try to restore that

$ PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > database.dump
$ heroku pg:backups restore 'https://www.dropbox.com/s/bunch_of_chars/database.dump?dl=0' HEROKU_POSTGRESQL_BLACK_URL -a MyAppname --confirm MyAppname

(I, of course, copied database.dump to Dropbox)

Errors:

Bash just hangs, showing:

r004 --restore--> HEROKU_POSTGRESQL_BLACK

<-[0KRunning... 0.00B

After several hours I cancel out of it.

And $ heroku pg:info showed 0 tables

4. Connect pgAdmin to Heroku

I use pg:config to get the details of my Heroku database. I add ssl, and enter the heroku 'dbname' in database restriction I then try to connect.

Errors:

pgAdmin just hangs, so a couple hours later I kill the process.

All advice I've seen has been to try pushing, or restoring the database. But this doesn't seem to be working for my configuration.

Any other advice/solutions please?

Many thanks in advance.

Upvotes: 0

Views: 1080

Answers (1)

hope yao
hope yao

Reputation: 1

I changed the link of Dropbox a little bit and then it works. What I changed is dl=0 into dl=1, so that heroku could download from Dropbox instead of open the downloading page.

Upvotes: 0

Related Questions