1

I have deployed my SpringBoot app to Heroku. Now I would like to copy my local PostgreSQL to Heroku.

I have found some information on devcenter.heroku.com. However I don't understand enough about the using of file db.changelog-master.yaml.

Could anyone give me details about the simplest solutions to copy the database?

1
  • At this point I have leant to create tables on Heroku's Postgres through Java API and Flyway. I am using script with CREATE statements. However a Big question is how to INSERT the existing data. Of course it is possible to create such script by hands and include there all the data, but I'm sure that there are should be more elegant way. Commented Apr 7, 2017 at 15:09

1 Answer 1

2

Create a valid dump of your local postgres database and host it somewhere publicly available. Now you will be able to restore this entire dataset (schema and records) with pg:backups:restore as shown here. The sole caveat here is that the target database must be completely empty for this to work. You can empty a Heroku postgres database with heroku pg:reset.

If you cannot take the approach listed above then you can run pg_restore directly from your local instance, provided your local version of Postgres is >= the target version of Postgres. This also applies to creating the dumpfile and is a requirement because pg utilities are not guaranteed to be forward compatible. Documentation for pg_restore is here.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. Is it possible to give me an additional advice. I copy my Postgres dump to Dropbox and give it the access to All. However Heroku says that Backup '...' not found. What is the prefered way to host the dump publicly?
So now I have uploaded my file to Amazon S3 and gave the public access. The link is s3.eu-west-2.amazonaws.com/kirillch/localizedb.sql. However Heroku again said that Backup '...' not found. I use the following command: heroku pg:backups:restore 's3.eu-west-2.amazonaws.com/kirillch/localizedb.sql' DATABASE_URL -a my_app_name
What response do you get back when you curl the file?
Response is: Backup 's3.eu-west-2.amazonaws.com/kirillch/localizedb.sql' not found for my_app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.