module HerokuPgBackupsArchive::ToolbeltHelper
Constants
- RETRIES
Public Class Methods
capture_backup()
click to toggle source
# File lib/heroku_pg_backups_archive/toolbelt_helper.rb, line 6 def capture_backup run("pg:backups:capture -a #{HerokuPgBackupsArchive.config.app_name} #{follower_db(HerokuPgBackupsArchive.config.app_name)}") end
fetch_backup_info(backup_id)
click to toggle source
# File lib/heroku_pg_backups_archive/toolbelt_helper.rb, line 14 def fetch_backup_info(backup_id) run("pg:backups:info #{backup_id} -a #{HerokuPgBackupsArchive.config.app_name}") end
fetch_backup_public_url(backup_id)
click to toggle source
# File lib/heroku_pg_backups_archive/toolbelt_helper.rb, line 10 def fetch_backup_public_url(backup_id) run("pg:backups:public-url #{backup_id} -a #{HerokuPgBackupsArchive.config.app_name}") end
Private Class Methods
follower_db(app)
click to toggle source
# File lib/heroku_pg_backups_archive/toolbelt_helper.rb, line 20 def follower_db(app) output = run("pg:info --app #{app} | grep Followers | head -n 1") output.split(" ").last end
run(arguments)
click to toggle source
# File lib/heroku_pg_backups_archive/toolbelt_helper.rb, line 25 def run(arguments) command = "#{HerokuPgBackupsArchive.config.heroku_toolbelt_path} #{arguments}" puts "Running: #{command}" retries_remaining = RETRIES begin output = `#{command} 2>&1` raise OperationFailedError.new(output) unless $?.success? puts "Output:\n#{output}" return output rescue OperationFailedError => ex retries_remaining -= 1 if retries_remaining > 0 puts "Failed, retrying..." retry else puts "Still failing after #{RETRIES} retries, giving up." raise ex end end end