Class: Backup::Syncer::Cloud

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/syncer/cloud.rb

Direct Known Subclasses

CloudFiles, S3

Defined Under Namespace

Classes: LocalFile, SyncContext

Constant Summary collapse

MUTEX =

Create a Mutex to synchronize certain parts of the code in order to prevent race conditions or broken STDOUT.

Mutex.new

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Attributes inherited from Base

#directories, #mirror, #path

Instance Method Summary collapse

Methods inherited from Base

#add

Methods included from Configuration::Helpers

#clear_defaults!, #load_defaults!

Methods included from CLI::Helpers

#command_name, #raise_if_command_failed!, #run, #utility

Constructor Details

#initialize(&block) ⇒ Cloud

Instantiates a new Cloud Syncer object and sets the default configuration specified in the Backup::Configuration::Syncer::S3. Then it sets the object defaults if particular properties weren’t set. Finally it’ll evaluate the users configuration file and overwrite anything that’s been defined.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/backup/syncer/cloud.rb', line 33

def initialize(&block)
  load_defaults!

  @path               ||= 'backups'
  @directories        ||= Array.new
  @mirror             ||= false
  @concurrency_type     = false
  @concurrency_level    = 2

  instance_eval(&block) if block_given?

  @path = path.sub(/^\//, '')
end

Instance Attribute Details

#concurrency_levelObject

Concurrency level - the number of threads or processors to use. Defaults to 2.



25
26
27
# File 'lib/backup/syncer/cloud.rb', line 25

def concurrency_level
  @concurrency_level
end

#concurrency_typeObject

Concurrency setting - defaults to false, but can be set to:

  • :threads

  • :processes



21
22
23
# File 'lib/backup/syncer/cloud.rb', line 21

def concurrency_type
  @concurrency_type
end

Instance Method Details

#perform!Object

Performs the Sync operation



49
50
51
52
53
54
55
56
# File 'lib/backup/syncer/cloud.rb', line 49

def perform!
  Logger.message("#{ syncer_name } started the syncing process:")

  directories.each do |directory|
    SyncContext.new(directory, repository_object, path).
      sync! mirror, concurrency_type, concurrency_level
  end
end