Class: RdiffBackupWrapper::Backup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Backup



5
6
7
# File 'lib/rdiff_backup_wrapper/backup.rb', line 5

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/rdiff_backup_wrapper/backup.rb', line 3

def config
  @config
end

Instance Method Details

#cmdObject



35
36
37
# File 'lib/rdiff_backup_wrapper/backup.rb', line 35

def cmd
  ['rdiff-backup', source, destination]
end

#destinationObject



13
14
15
# File 'lib/rdiff_backup_wrapper/backup.rb', line 13

def destination
  ensure_slash_end('destination')
end

#ensure_slash_end(key) ⇒ Object



17
18
19
20
21
22
# File 'lib/rdiff_backup_wrapper/backup.rb', line 17

def ensure_slash_end(key)
  if config[key].end_with? '/'
    return config[key]
  end
  config[key] + '/'
end

#runObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/rdiff_backup_wrapper/backup.rb', line 24

def run
  command = [
    'nice',
    'ionice', '-c', '3',
  ] + cmd
  Open3.popen3(command) do |i,o,e,t|
      p o.read
      p e.read
  end
end

#sourceObject



9
10
11
# File 'lib/rdiff_backup_wrapper/backup.rb', line 9

def source
  ensure_slash_end('source')
end

#to_sObject



39
40
41
# File 'lib/rdiff_backup_wrapper/backup.rb', line 39

def to_s
  "<Backup name=#{config['name']}>"
end