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

Version Path
ey_cloud_server-1.4.44 lib/ey_backup/backend.rb
ey_cloud_server-1.4.43 lib/ey_backup/backend.rb
ey_cloud_server-1.4.41 lib/ey_backup/backend.rb
ey_cloud_server-1.4.40 lib/ey_backup/backend.rb
ey_cloud_server-1.4.39 lib/ey_backup/backend.rb
ey_cloud_server-1.4.37 lib/ey_backup/backend.rb
ey_cloud_server-1.4.37.ruby19 lib/ey_backup/backend.rb
ey_cloud_server-1.4.36 lib/ey_backup/backend.rb
ey_cloud_server-1.4.34 lib/ey_backup/backend.rb
ey_cloud_server-1.4.33 lib/ey_backup/backend.rb
ey_cloud_server-1.4.32 lib/ey_backup/backend.rb
ey_cloud_server-1.4.31 lib/ey_backup/backend.rb
ey_cloud_server-1.4.29 lib/ey_backup/backend.rb
ey_cloud_server-1.4.28 lib/ey_backup/backend.rb
ey_cloud_server-1.4.28.pre lib/ey_backup/backend.rb
ey_cloud_server-1.4.26 lib/ey_backup/backend.rb