Class: Backup::Storage::Base

Inherits:
Object
  • Object
show all
Includes:
Config::Helpers
Defined in:
lib/backup/storage/base.rb

Direct Known Subclasses

CloudFiles, Dropbox, FTP, Local, Ninefold, RSync, S3, SCP, SFTP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Config::Helpers

included

Constructor Details

#initialize(model, storage_id = nil, &block) ⇒ Base

storage_id is a user-defined string used to uniquely identify multiple storages of the same type. If multiple storages of the same type are added to a single backup model, this identifier must be set. This will be appended to the YAML storage file used for cycling backups.



24
25
26
27
28
29
30
31
# File 'lib/backup/storage/base.rb', line 24

def initialize(model, storage_id = nil, &block)
  @model = model
  @package = model.package
  @storage_id = storage_id.to_s.gsub(/\W/, '_') if storage_id

  load_defaults!
  instance_eval(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers

Instance Attribute Details

#keepObject

Sets the limit to how many backups to keep in the remote location. If exceeded, the oldest will be removed to make room for the newest



15
16
17
# File 'lib/backup/storage/base.rb', line 15

def keep
  @keep
end

#modelObject (readonly)

Returns the value of attribute model.



17
18
19
# File 'lib/backup/storage/base.rb', line 17

def model
  @model
end

#packageObject (readonly)

Returns the value of attribute package.



17
18
19
# File 'lib/backup/storage/base.rb', line 17

def package
  @package
end

#pathObject

Base path on the remote where backup package files will be stored.



10
11
12
# File 'lib/backup/storage/base.rb', line 10

def path
  @path
end

#storage_idObject (readonly)

Returns the value of attribute storage_id.



17
18
19
# File 'lib/backup/storage/base.rb', line 17

def storage_id
  @storage_id
end

Instance Method Details

#perform!Object



33
34
35
36
37
38
# File 'lib/backup/storage/base.rb', line 33

def perform!
  Logger.info "#{ storage_name } Started..."
  transfer!
  cycle! if respond_to?(:cycle!, true) && keep.to_i > 0
  Logger.info "#{ storage_name } Finished!"
end