Sha256: dcded9cfdbf38fea656b26434b68d6037ceab85d5809dc15637adde1d3b6fad5
Contents?: true
Size: 1.11 KB
Versions: 16
Compression:
Stored size: 1.11 KB
Contents
require 'fog' module EY module Backup class Backend include EY::Backup::Logging extend EY::Backup::Logging def initialize(secret_id, secret_key, region, bucket_name) @bucket_minder = EY::BucketMinder.new(secret_id, secret_key, bucket_name, region) @s3 = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => secret_id, :aws_secret_access_key => secret_key, :region => region) end attr_reader :bucket_minder def start_upload(filenames, environment_name, database_name) filenames.each do |filename| begin object_name = "#{environment_name}.#{database_name}/#{File.basename(filename)}" info "Starting upload: #{filename}" @s3.put_object(@bucket_minder.bucket_name, object_name, File.open(filename,'r')) info "Successful upload: #{filename}" rescue => e retries ||= 5 retries -= 1 raise e if retries == 0 warn "retrying upload of #{filename}. Got: #{e.inspect}" retry end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems