Class: Backup::Syncer::Cloud::Base

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

Direct Known Subclasses

CloudFiles

Constant Summary collapse

MUTEX =
Mutex.new

Instance Attribute Summary collapse

Attributes inherited from Base

#excludes, #mirror, #path, #syncer_id

Instance Method Summary collapse

Methods inherited from Base

#add, #directories, #exclude

Methods included from Config::Helpers

included

Methods included from Utilities::Helpers

#utility_remote

Constructor Details

#initialize(syncer_id = nil, &block) ⇒ Base

Returns a new instance of Base.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/backup/syncer/cloud/base.rb', line 29

def initialize(syncer_id = nil, &block)
  super
  instance_eval(&block) if block_given?

  @thread_count   ||= 0
  @max_retries    ||= 10
  @retry_waitsec  ||= 30

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

Dynamic Method Handling

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

Instance Attribute Details

#max_retriesObject

Number of times to retry failed operations.

Default: 10



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

def max_retries
  @max_retries
end

#retry_waitsecObject

Time in seconds to pause before each retry.

Default: 30



27
28
29
# File 'lib/backup/syncer/cloud/base.rb', line 27

def retry_waitsec
  @retry_waitsec
end

#thread_countObject

Number of threads to use for concurrency.

Default: 0 (no concurrency)



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

def thread_count
  @thread_count
end

Instance Method Details

#perform!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/backup/syncer/cloud/base.rb', line 41

def perform!
  log!(:started)
  @transfer_count = 0
  @unchanged_count = 0
  @skipped_count = 0
  @orphans = thread_count > 0 ? Queue.new : []

  directories.each {|dir| sync_directory(dir) }
  orphans_result = process_orphans

  Logger.info "\nSummary:"
  Logger.info "\s\sTransferred Files: #{ @transfer_count }"
  Logger.info "\s\s#{ orphans_result }"
  Logger.info "\s\sUnchanged Files: #{ @unchanged_count }"
  Logger.warn "\s\sSkipped Files: #{ @skipped_count }" if @skipped_count > 0
  log!(:finished)
end