Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku - dump and load single table to shared postgres database

I wonder if there is an easy way to dump or load the content of just one table to heroku shared database (postgres). There is pgbackups addon reccomended by heroku but according to docs it supports dumping and loading the whole database.

What I need is to just dump/load single table.

like image 311
januszm Avatar asked Sep 18 '12 20:09

januszm


1 Answers

You can use Taps (https://devcenter.heroku.com/articles/taps) to pull data down from your PG database. Using Taps, you can do specific table(s), like such:

heroku db:pull --tables users

You can do more than one table as well where the table names are comma delimited, like:

heroku db:pull --tables users,posts

Edit: As some comments have pointed out, taps has been deprecated and replaced.

New mechanism is through pg:pull and pg:push which can be seen by their new docs (https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull).

No longer supporting individual tables, you can pull the db to your local by the following example:

heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

or updating the remote from your local:

heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi
like image 94
OnResolve Avatar answered Oct 05 '22 01:10

OnResolve