Sha256: 7f2b564aeb91158fcb91b01de7fd0211f5bc7a7ccd4593edfb4be9b8a6dde706
Contents?: true
Size: 1.25 KB
Versions: 7
Compression:
Stored size: 1.25 KB
Contents
require "open-uri" require "aws-sdk" require "base64" module HerokuPgBackupsArchive class BackupArchive def self.perform(backup) backup_archive = new(backup) backup_archive.perform end def initialize(backup) @backup = backup end def perform s3.put_object(write_parameters) end private attr_reader :backup def s3 @s3 ||= Aws::S3::Client.new( access_key_id: HerokuPgBackupsArchive.config.aws_access_key_id, secret_access_key: HerokuPgBackupsArchive.config.aws_secret_access_key, region: HerokuPgBackupsArchive.config.aws_region ) end def archive_path "#{backup.finished_at.strftime("%Y/%m/%d")}/#{backup.finished_at.iso8601}" end def backup_data open(backup.url) end def write_parameters { body: backup_data, bucket: HerokuPgBackupsArchive.config.bucket_name, key: archive_path }.merge(sse_customer_options) end def sse_customer_options unless HerokuPgBackupsArchive.config.sse_customer_key.nil? { sse_customer_algorithm: :AES256, sse_customer_key: HerokuPgBackupsArchive.config.sse_customer_key } else {} end end end end
Version data entries
7 entries across 7 versions & 1 rubygems