Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgbackups and other local commands #134

Open
jkamenik opened this issue May 8, 2013 · 2 comments
Open

pgbackups and other local commands #134

jkamenik opened this issue May 8, 2013 · 2 comments

Comments

@jkamenik
Copy link

jkamenik commented May 8, 2013

I have a rails app and before I do a migration I do a manual backup just incase I have to rollback. I can't use run because it needs to execute locally, but sh_heroku fails:

heroku-toolbelt/2.39.2 (x86_64-darwin10.8.0) ruby/1.9.3
help pgbackups --app waterfalldev
 !    `help pgbackups` is not a heroku command.
 !    See `heroku help` for a list of available commands.
rake aborted!
Command failed with status (1): [heroku help pgbackups --app waterfalldev]

The current sh_heroku can't deal with executing local commands. I think it has to do with how system 'command args' is processed differently then system 'command', args.

There has to be a better then this, but here is what I came up with.

class HerokuSan::Stage
  public :sh_heroku
  def sh_heroku_local(*command)
    @debug = true
    preflight_check_for_cli
    cmd = (['heroku'] + command + ['--app', app]).compact
    show_command = cmd.join(' ')
    $stderr.puts show_command if @debug
    ok = system show_command
    status = $?
    ok or fail "Command failed with status (#{status.exitstatus}): [heroku #{show_command}]"
  end
end

Results of using sh_heroku_local

heroku-toolbelt/2.39.2 (x86_64-darwin10.8.0) ruby/1.9.3
heroku help pgbackups --app waterfalldev
Usage: heroku pgbackups

 list captured backups

Additional commands, type "heroku help COMMAND" for more details:

  pgbackups:capture [DATABASE]                           #  capture a backup from a database id
  pgbackups:destroy BACKUP_ID                            #  destroys a backup
  pgbackups:restore [<DATABASE> [BACKUP_ID|BACKUP_URL]]  #  restore a backup to a database
  pgbackups:url [BACKUP_ID]                              #  get a temporary URL for a backup
@jturkel
Copy link

jturkel commented Aug 7, 2013

I was able to get this working by doing the following:

stage.send(:sh_heroku, 'pgbackups:capture', '--expire')

Notice you need to pass the command args as separate arguments to the method rather than encoding the command and args in a single string. I'd still love a more out of the box solution for this though :)

@profsmallpine
Copy link

If anybody is still looking at this, I used this:

def backup_database
  puts "Create pg:backup for #{@stage.name}"
  @stage.heroku.sh(@stage.app, "pg:backups", "capture")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants