12

I'm getting this message even though I've used heroku db:pull a million times. For some reason it's no longer working even though I haven't even touched my code. Any ideas?

The full error message is

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

kevinkt
  • 735
  • 12
  • 24

7 Answers7

17

For now, we can still use heroku-legacy-taps until the taps gods decide to deprovision the taps servers.

Run: heroku plugins:install https://github.com/heroku/heroku-legacy-taps.git

Then continue your db:push and db:pull workflow as usual. (thanks to GantMan for the hint)

Arcolye
  • 6,968
  • 4
  • 34
  • 28
  • easy peasy... I'm not looking forward to them dropping support for this. We're supposed to be using pg backup, right? I never really understood it. – Dudo Nov 14 '13 at 01:07
  • Unfortunately, this solution no longer works. Using db:push or db:pull spits out "db:push and db:pull have been removed and replaced with pg:push and pg:pull." – Hernan S. Mar 24 '14 at 15:47
6

Since the taps servers will be decommissioned at some future point, the plugin is probably not the best long term solution. But of course you can run your own taps server.

Steps

Step 1: Start Your taps server

taps server `heroku config:get DATABASE_URL` db db

Step 2: Run the taps client

In a different shell:

taps pull sqlite://db/development.sqlite3 http://db:db@localhost:5000

Step 3: Shut down the taps server

Once the import is done you can shutdown the server with the normal Ctrl-C key combination.

Notes

  • This will pull my production database down into a local SQLite database. Of course if you are using MySQL or something locally just replace the sqlite URI with the equivalent MySQL URI.
  • Taps requires you to set a username/password. Since I am just running it locally for a short time I just use "db" for both. If you change these you will need to also update the username/password in the URL for step 2.
  • You can also use taps push to copy data to the production server although you should obviously do that with caution.
  • Taps has a number of bugs it has acquired over time due to the lack of activity by the maintainer:

@wijet recently forked taps and incorporated some of the most important patches. He has named his gem "taps-taps" if you are looking for an easy out-of-the-box install.

Eric Anderson
  • 3,692
  • 4
  • 31
  • 34
2

This is still possible. Just run

heroku plugins:install https://github.com/heroku/heroku-taps.git

You'll be able to do your classic stuff, it's just a plugin now.

If you're having trouble still, you may need to make sure some other gems are installed. You can also run the following to be sure:

gem install heroku taps sequel

I hope this helps! I love db:push/pull just like the rest of the world, and I'm sad to see it go.

If you're still having problems take a look at this one: https://github.com/heroku/heroku-legacy-taps

GOODLUCK!

Gant Laborde
  • 6,484
  • 1
  • 21
  • 30
  • The first one didn't work for me. `Error: undefined method 'database_session' for # (NoMethodError)` But the second one did. Thanks. I'll put it as an answer. – Arcolye Oct 16 '13 at 09:36
2

I used to use db:pull and it worked fine. After it was removed, I tried pg:pull but it is just not working for me.

I found a different solution. If your local database is PostgreSQL, and you have the pgbackups addon enabled, this is the sequence of commands I'm using to copy the remote DB to my local machine:

$ wget "`heroku pgbackups:url --app app-name`" -O backup.dump
$ # Create the local database first, if it's not created yet. Then:
$ pg_restore -d database-name -c backup.dump -U database-user-name -O --no-acl -h localhost

Replace app-name, database-name and database-user-name with your own info.

You'll likely want to ask heroku to make a backup just before you pull your data:

heroku pgbackups:capture --expire

otherwise you get the data from whenever it did its own backup.

Hernan S.
  • 2,604
  • 3
  • 17
  • 15
0

This is the error message I got when I tried db:pull.

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

Have you tried pg:pull?

Usage: heroku pg:pull <REMOTE_SOURCE_DATABASE> <LOCAL_TARGET_DATABASE>

xander-miller
  • 529
  • 5
  • 12
  • I'm trying to use pg:pull right now, but it's frustrating because I guess heroku db:pull is now deprecated? But pg:pull is not working because my postgresql db version is not the right one. I'm trying to fix it right now. – kevinkt Oct 02 '13 at 23:13
  • `db:pull` isn't deprecated... it's never been a command on Heroku. – zeantsoi Oct 02 '13 at 23:51
  • 3
    According to this it at least was https://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku – amitamb Oct 03 '13 at 13:23
  • 1
    I'm getting the same thing. It was so useful I hate to see that they just removed it. You can still use taps directly to do the same thing. Just requires a few more steps. – Eric Anderson Oct 03 '13 at 23:08
  • I use this a lot as well. @EricAnderson, what are the steps required? I've tried installing as a plugin as GantMan below suggests but that didn't work. – Raoot Oct 15 '13 at 18:36
  • 1
    @RyanBerry - I created an answer with my steps as well as notes for working around bugs in Taps. – Eric Anderson Oct 16 '13 at 18:51
0

Looks like db:pull etc is being deprecated & moved

See here https://github.com/heroku/heroku-pg-extras/issues/42

I found that the ability of db:push & pull to move single eg static tables of data up & down from dev to staging to production was invaluable - now looks like you need to create a new empty database and do an entire dump into it and then run pg commands to move an individual table

Mitch
  • 1,017
  • 1
  • 13
  • 25
0

I found my answer here, but I put it in a rake task. I think this is a sensible way to deal with this situation. If you're running a local instance of postgres to work with your postgres on Heroku, you might try something like this:

# lib/tasks/database.rake

namespace :database do
  desc "Gets the database from heroku and restores it to development"
  task :pull => :environment do
    dumpfile =  'tmp/latest.dump'
    db_config = Rails.application.config.database_configuration[Rails.env]
    File.delete(dumpfile) if File.exist?(dumpfile)
    `heroku pgbackups:capture --app app-name-here`
    system("curl -o #{dumpfile} `heroku pgbackups:url --app app-name-here`")
    `pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{db_config['database']} #{dumpfile}`
  end
end

Now, anytime I wish to pull my production data into dev I just run rake database:pull

This is a very rudimentary solution, but I only need it to do this one thing in my case.

counterbeing
  • 2,721
  • 2
  • 27
  • 47