class Backup::Storage::CloudFiles

Attributes

api_key[RW]

Rackspace CloudFiles Credentials

auth_url[RW]

Rackspace Auth URL (optional)

container[RW]

Rackspace Container Name

days_to_keep[RW]

If set, all backup package files (including SLO segments) will be scheduled for automatic removal by the server.

The `keep` option should not be used if this is set, unless you're transitioning from the `keep` option.

fog_options[RW]

Additional options to pass along to fog. e.g. Fog::Storage.new({ :provider => 'Rackspace' }.merge(fog_options))

max_retries[RW]

Number of times to retry failed operations.

Default: 10

region[RW]

Rackspace Region (optional)

retry_waitsec[RW]

Time in seconds to pause before each retry.

Default: 30

segment_size[RW]

SLO Segment size, specified in MiB.

Each package file larger than segment_size will be uploaded as a Static Large Objects (SLO).

Defaults to 0 for backward compatibility (pre v.3.7.0), since segments_container would be required.

Minimum: 1 (0 disables SLO support) Maximum: 5120 (5 GiB)

segments_container[RW]

Rackspace Container Name for SLO Segments Required if segment_size is set. Must be different from container.

servicenet[RW]

Rackspace Service Net (LAN-based transfers to avoid charges and improve performance)

username[RW]

Rackspace CloudFiles Credentials

Public Class Methods

new(model, storage_id = nil) click to toggle source
Calls superclass method Backup::Storage::Base::new
# File lib/backup/storage/cloud_files.rb, line 74
def initialize(model, storage_id = nil)
  super

  @servicenet         ||= false
  @segment_size       ||= 0
  @max_retries        ||= 10
  @retry_waitsec      ||= 30

  @path ||= 'backups'
  path.sub!(/^\//, '')

  check_configuration
end

Private Instance Methods

check_configuration() click to toggle source
# File lib/backup/storage/cloud_files.rb, line 133
      def check_configuration
        required = %w{ username api_key container }
        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 segment_size > 0 && segments_container.to_s.empty?
          Configuration Error
          #segments_container is required if #segment_size is > 0
        EOS

        raise Error, <<-EOS if container == segments_container
          Configuration Error
          #container and #segments_container must not be the same container.
        EOS

        raise Error, <<-EOS if segment_size > 5120
          Configuration Error
          #segment_size is too large (max 5120)
        EOS
      end
cloud_io() click to toggle source
# File lib/backup/storage/cloud_files.rb, line 90
def cloud_io
  @cloud_io ||= CloudIO::CloudFiles.new(
    :username           => username,
    :api_key            => api_key,
    :auth_url           => auth_url,
    :region             => region,
    :servicenet         => servicenet,
    :container          => container,
    :segments_container => segments_container,
    :segment_size       => segment_size,
    :days_to_keep       => days_to_keep,
    :max_retries        => max_retries,
    :retry_waitsec      => retry_waitsec,
    :fog_options        => fog_options
  )
end
remove!(package) click to toggle source

Called by the Cycler. Any error raised will be logged as a warning.

# File lib/backup/storage/cloud_files.rb, line 120
def remove!(package)
  Logger.info "Removing backup package dated #{ package.time }..."

  remote_path = remote_path_for(package)
  objects = cloud_io.objects(remote_path)

  raise Error, "Package at '#{ remote_path }' not found" if objects.empty?

  slo_objects, objects = objects.partition(&:slo?)
  cloud_io.delete_slo(slo_objects)
  cloud_io.delete(objects)
end
transfer!() click to toggle source
# File lib/backup/storage/cloud_files.rb, line 107
def transfer!
  package.filenames.each do |filename|
    src = File.join(Config.tmp_path, filename)
    dest = File.join(remote_path, filename)
    Logger.info "Storing '#{ container }/#{ dest }'..."
    cloud_io.upload(src, dest)
  end

  package.no_cycle = true if days_to_keep
end