Sha256: 9b176d36ec022997b1947a6ddbe1aa34e8816e9c3ddff504e824f1ef554b4200

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

require "heroku_pull/version"
require "heroku_pull/railtie"
require "yaml"

module HerokuPull
  class << self
    def capture
      cmd = "heroku pgbackups:capture --expire"
      puts "Capture the database..."
      puts cmd
      system cmd
    end

    def download
      cmd = "wget -O #{filename} `heroku pgbackups:url`"
      puts "Download backup file..."
      puts cmd
      system cmd
    end

    def restore
      cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database} #{filename}"
      puts "Restore local database..."
      puts cmd
      system cmd
    end

    def filename
      "./tmp/heroku_pull.sql"
    end

    def database(config_path = './config/database.yml')
      ENV['RAILS_ENV'] ||= 'development'
      config   = YAML::load_file(config_path)
      database = config[ENV['RAILS_ENV']]['database']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heroku_pull-0.0.1 lib/heroku_pull.rb