user984621
user984621

Reputation: 48453

Heroku - how to pull data from database to the local database?

I am trying to fetch database on Heroku and the data from there to save into my local database.

When I try

heroku db:pull

and confirm the name of the app, I get:

 !    db:push and db:pull have been removed and replaced with pg:push and pg:pull.
 !    For more information, please see:
 !      devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

Ok, so:

pg:pull

returns:

-bash: pg:pull: command not found

heroku pg:pull

returns

 !    `pg:pull` is not a heroku command.
 !    Perhaps you meant `db:pull` or `pg:psql`.
 !    See `heroku help` for a list of available commands.

Thus, how to properly pull the data?

Upvotes: 3

Views: 5959

Answers (2)

ChrisBarthol
ChrisBarthol

Reputation: 4959

Per the Heroku Postgres help, you have to specify the database you are pulling from and to for pg:pull to work.

$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

This command will create a new local database named mylocaldb and then pull data from the database at DATABASE_URL from the app sushi. To prevent accidental data overwrites and loss, the local database must not exist. You will be prompted to drop an already existing local database before proceeding.

This also assumes you have Postgres on your local machine.

heroku pg:info will give you all available information, such as name, on your Heroku databases.

Upvotes: 7

magnum
magnum

Reputation: 1090

in your project's dir, after installing taps gem, you can try using

taps server `heroku config:get DATABASE_URL` db db

to start a taps server, and then

taps push mysql://[usernme]:[password]@[host]/[database] http://db:db@localhost:500

to sync local db to heroku through taps

Upvotes: 0

Related Questions