简体   繁体   中英

Heroku db:pull 'db:pull is not a heroku command'

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.

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)

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.

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!

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.

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>

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM