Class: Nearline::Models::System

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/nearline/system.rb

Overview

The System has the responsibility of identifying what the target was for a backup and relating all Manifests and ArchivedFiles associated with the target system.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.backup(system_name, backup_paths, backup_exclusions) ⇒ Object

Method used by the Nearline module to backup the system



36
37
38
39
# File 'lib/nearline/system.rb', line 36

def self.backup(system_name, backup_paths, backup_exclusions)
  system = self.for_name(system_name)
  system.backup(backup_paths, backup_exclusions)
end

.for_name(system_name) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/nearline/system.rb', line 14

def self.for_name(system_name)
  system = self.find_by_name(system_name)
  return system unless system.nil?
  system = self.new(:name => system_name)
  system.save!
  system
end

.restore_all_missing(system_name, latest_date_time) ⇒ Object

Method used by the Nearline module to restore the system



46
47
48
49
# File 'lib/nearline/system.rb', line 46

def self.restore_all_missing(system_name, latest_date_time)
  system = self.for_name(system_name)
  system.restore_all_missing(latest_date_time)
end

.what_would_restore(system_name, latest_date_time) ⇒ Object



55
56
57
58
# File 'lib/nearline/system.rb', line 55

def self.what_would_restore(system_name, latest_date_time)
  system = self.for_name(system_name)
  system.what_would_restore(latest_date_time)
end

Instance Method Details

#backup(backup_paths, backup_exclusions) ⇒ Object



41
42
43
# File 'lib/nearline/system.rb', line 41

def backup(backup_paths, backup_exclusions)
  Manifest.backup(self, backup_paths, backup_exclusions)
end

#before_destroyObject



64
65
66
67
68
# File 'lib/nearline/system.rb', line 64

def before_destroy
  for manifest in self.manifests
    manifest.destroy
  end
end

#latest_manifest_as_of(latest_date_time = Time.now) ⇒ Object

Find the latest Manifest for a system given the latest_date_time as an upper limit



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

def latest_manifest_as_of(latest_date_time = Time.now)
  m_result = Manifest.find(:first,
    :conditions => 
      ["system_id = ? and created_at <= ?",
      self.id, latest_date_time],
    :order => "created_at desc"
  )
  raise "No manifest found" if m_result.nil?
  m_result        
end

#restore_all_missing(latest_date_time) ⇒ Object



51
52
53
# File 'lib/nearline/system.rb', line 51

def restore_all_missing(latest_date_time)
  Manifest.restore_all_missing(self, latest_date_time)
end

#what_would_restore(latest_date_time = Time.now) ⇒ Object



60
61
62
# File 'lib/nearline/system.rb', line 60

def what_would_restore(latest_date_time = Time.now)
  Manifest.what_would_restore(self, latest_date_time)
end