Class: Backup::Main

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

Class Method Summary collapse

Class Method Details

.email(options) ⇒ Object



41
42
43
44
45
46
# File 'lib/backup.rb', line 41

def self.email(options)
  puts "sending email to #{options[:to]}"
  unless @@options[:pretend]
    Mail.new(options).deliver!
  end
end

.run(shell) ⇒ Object



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

def self.run(shell)
  puts shell.red
  if @@options[:pretend]
    true
  else
    results = `#{shell}`
    return false if $?.to_i > 0
    results
  end
end

.start(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/backup.rb', line 11

def self.start(options)
  @@options = options

  @configuration = Backup::Configuration::Base.new
  @configuration.instance_eval { eval File.read(options[:config]) }

  @configuration.storage.map do |storage_key, storage_value|
    @configuration.server.map do |name, config|
      next if options[:name].size > 0 && options[:name].select {|n| n == name }.size == 0

      server = Backup::Server.new
      server.name    = name
      server.config  = config
      server.storage = Backup::Storage.new(storage_key, storage_value)
      server.backup
    end
  end
end