Sha256: f6ce12f070f68218443ac0ec1b4c749393f83bd99d0edbf80503e429c1b72209
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require 'fog/aws' 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 # remove partial or failed uploads @s3.delete_object(@bucket_minder.bucket_name, object_name) rescue nil raise e if retries == 0 warn "retrying upload of #{filename}. Got: #{e.inspect}" retry end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ey_cloud_server-1.4.51 | lib/ey_backup/backend.rb |
ey_cloud_server-1.4.50 | lib/ey_backup/backend.rb |
ey_cloud_server-1.4.49 | lib/ey_backup/backend.rb |