class PgbackupsArchive::Storage

Public Class Methods

new(key, file) click to toggle source
# File lib/pgbackups-archive/storage.rb, line 6
def initialize(key, file)
  @key = key
  @file = file
end

Public Instance Methods

bucket() click to toggle source
# File lib/pgbackups-archive/storage.rb, line 21
def bucket
  connection.directories.get ENV["PGBACKUPS_BUCKET"]
end
connection() click to toggle source
# File lib/pgbackups-archive/storage.rb, line 11
def connection
  Fog::Storage.new({
    :provider              => "AWS",
    :aws_access_key_id     => ENV["PGBACKUPS_AWS_ACCESS_KEY_ID"],
    :aws_secret_access_key => ENV["PGBACKUPS_AWS_SECRET_ACCESS_KEY"],
    :region                => ENV["PGBACKUPS_REGION"],
    :persistent            => false
  })
end
store() click to toggle source
# File lib/pgbackups-archive/storage.rb, line 25
def store
  options = {:key => @key, :body => @file, :public => false, :encryption => "AES256"}

  if ENV["PGBACKUPS_MULTIPART_CHUNK_SIZE"]
    options.merge!(:multipart_chunk_size => ENV["PGBACKUPS_MULTIPART_CHUNK_SIZE"].to_i)
  end

  bucket.files.create(options)
end