Class: PXCBackup::Backup

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, path) ⇒ Backup

Returns a new instance of Backup.



5
6
7
8
9
# File 'lib/pxcbackup/backup.rb', line 5

def initialize(repo, path)
  @repo = repo
  @path = path
  raise 'invalid backup name' unless match
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

Class Method Details

.regexpObject



11
12
13
# File 'lib/pxcbackup/backup.rb', line 11

def self.regexp
  /\/(\d+)_(full|incr)\.(xbstream|tar)(\.xbcrypt)?$/
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
22
23
# File 'lib/pxcbackup/backup.rb', line 19

def <=>(other)
  compare = time <=> other.time
  compare = remote? ? -1 : 1 if compare == 0 && remote? != other.remote?
  compare
end

#==(other) ⇒ Object



15
16
17
# File 'lib/pxcbackup/backup.rb', line 15

def ==(other)
  @path == other.path && @repo == other.repo
end

#deleteObject



59
60
61
# File 'lib/pxcbackup/backup.rb', line 59

def delete
  @repo.delete(self)
end

#encrypted?Boolean

Returns:



43
44
45
# File 'lib/pxcbackup/backup.rb', line 43

def encrypted?
  match[:encrypted]
end

#full?Boolean

Returns:



47
48
49
# File 'lib/pxcbackup/backup.rb', line 47

def full?
  type == :full
end

#incremental?Boolean

Returns:



51
52
53
# File 'lib/pxcbackup/backup.rb', line 51

def incremental?
  type == :incremental
end

#remote?Boolean

Returns:



55
56
57
# File 'lib/pxcbackup/backup.rb', line 55

def remote?
  @repo.is_a? RemoteRepo
end

#streamObject



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

def stream
  match[:stream].to_sym
end

#stream_commandObject



63
64
65
# File 'lib/pxcbackup/backup.rb', line 63

def stream_command
  @repo.stream_command(self)
end

#timeObject



29
30
31
# File 'lib/pxcbackup/backup.rb', line 29

def time
  Time.at(match[:timestamp].to_i)
end

#to_sObject



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

def to_s
  time.to_s
end

#typeObject



33
34
35
36
37
# File 'lib/pxcbackup/backup.rb', line 33

def type
  type = match[:type]
  type = 'incremental' if type == 'incr'
  type.to_sym
end