class Backup::Syncer::Cloud::S3
Attributes
bucket[RW]
Amazon S3
bucket name
encryption[RW]
Encryption algorithm to use for Amazon Server-Side Encryption
Supported values:
-
:aes256
Default: nil
fog_options[RW]
Additional options to pass along to fog. e.g. Fog::Storage.new({ :provider => ‘AWS’ }.merge(fog_options
))
region[RW]
Region of the specified S3
bucket
storage_class[RW]
Public Class Methods
new(syncer_id = nil)
click to toggle source
Calls superclass method
Backup::Syncer::Cloud::Base::new
# File lib/backup/syncer/cloud/s3.rb, line 47 def initialize(syncer_id = nil) super @storage_class ||= :standard check_configuration end
Private Instance Methods
check_configuration()
click to toggle source
# File lib/backup/syncer/cloud/s3.rb, line 83 def check_configuration required = if use_iam_profile %w(bucket) else %w(access_key_id secret_access_key bucket) end raise Error, <<-EOS if required.map { |name| send(name) }.any?(&:nil?) Configuration Error #{required.map { |name| "##{name}" }.join(", ")} are all required EOS raise Error, <<-EOS if encryption && encryption.to_s.upcase != "AES256" Configuration Error #encryption must be :aes256 or nil EOS classes = ["STANDARD", "REDUCED_REDUNDANCY"] raise Error, <<-EOS unless classes.include?(storage_class.to_s.upcase) Configuration Error #storage_class must be :standard or :reduced_redundancy EOS end
cloud_io()
click to toggle source
# File lib/backup/syncer/cloud/s3.rb, line 57 def cloud_io @cloud_io ||= CloudIO::S3.new( access_key_id: access_key_id, secret_access_key: secret_access_key, use_iam_profile: use_iam_profile, bucket: bucket, region: region, encryption: encryption, storage_class: storage_class, max_retries: max_retries, retry_waitsec: retry_waitsec, # Syncer can not use multipart upload. chunk_size: 0, fog_options: fog_options ) end
get_remote_files(remote_base)
click to toggle source
# File lib/backup/syncer/cloud/s3.rb, line 74 def get_remote_files(remote_base) hash = {} cloud_io.objects(remote_base).each do |object| relative_path = object.key.sub(remote_base + "/", "") hash[relative_path] = object.etag end hash end