Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer initial PostgreSQL database from development to Heroku production

I have an initial set of production data stored locally in the development database that I'd like to migrate to production for a starting point for data. What's the best way to transfer this data?

It does not seem evident if there is a way to use pgbackups as per the instructions. Perhaps I have to run a manual backup of some sort locally and then push it over with pgbackups and if that is the case, I'd appreciate some specific instructions on accomplishing this.

like image 965
ylluminate Avatar asked Jun 20 '26 10:06

ylluminate


2 Answers

After some additional digging and an answer from Heroku, the answer for importation of initial data is to:

1) If using PGSQL locally, first dump the data:

pg_dump -U your_username your_database_name -f backup.sql

2) Then follow the instructions found here for importation to Heroku's database: http://devcenter.heroku.com/articles/pgbackups#importing_from_a_backup

like image 199
ylluminate Avatar answered Jun 23 '26 01:06

ylluminate


First dump your local database using pg_dump:

pg_dump -Fc --no-acl --no-owner -h ... mydb > mydb.dump

and then use heroku pgbackups:restore:

heroku pgbackups:restore heroku-database-url url-to-your-mydb.dump-file

Note that the mydb.dump file needs to be accessible by the Heroku servers.

The Heroku Dev Center page has detailed instructions:

https://devcenter.heroku.com/articles/heroku-postgres-import-export

like image 23
mu is too short Avatar answered Jun 23 '26 01:06

mu is too short