0

I am writing a script for periodically dumping the database and uploading it to S3

I have this method call utilizes the Heroku gem and that gets called from a rake task at various intervals

def dump_database
  Rails.logger.info "Dumping database into temporary file."

  # Stamp the filename
  datestamp = Time.now.strftime("%d-%m-%Y_%H-%M-%S")    

  # Drop it in the db/backups directory temporarily
  file_path = "#{Rails.root}/db/backups/APPNAME_#{Rails.env}_#{datestamp}_dump.sql.gz" 

  # Dump and zip the backup file
  sh "heroku pgbackups:capture --expire -a APPNAME-#{Rails.env}"
  sh "curl -o #{file_path} `heroku pgbackups:url -a APPNAME-#{Rails.env}` | gzip > #{file_path}" 

  return file_path
end

Problem is that when I call the

sh "heroku pgbackups:capture --expire -a APPNAME-#{Rails.env}"

Heroku asks for credentials (email/password) to me entered into the terminal

Cant this be done without entering credentials?

Tarlen
  • 3,657
  • 8
  • 30
  • 54

0 Answers0