class PXCBackup::Backup
Attributes
path[R]
repo[R]
Public Class Methods
new(repo, path)
click to toggle source
# File lib/pxcbackup/backup.rb, line 5 def initialize(repo, path) @repo = repo @path = path raise 'invalid backup name' unless match end
regexp()
click to toggle source
# File lib/pxcbackup/backup.rb, line 11 def self.regexp /\/(\d+)_(full|incr)\.(xbstream|tar)(\.xbcrypt)?$/ end
Public Instance Methods
<=>(other)
click to toggle source
# 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)
click to toggle source
# File lib/pxcbackup/backup.rb, line 15 def ==(other) @path == other.path && @repo == other.repo end
delete()
click to toggle source
# File lib/pxcbackup/backup.rb, line 59 def delete @repo.delete(self) end
encrypted?()
click to toggle source
# File lib/pxcbackup/backup.rb, line 43 def encrypted? match[:encrypted] end
full?()
click to toggle source
# File lib/pxcbackup/backup.rb, line 47 def full? type == :full end
incremental?()
click to toggle source
# File lib/pxcbackup/backup.rb, line 51 def incremental? type == :incremental end
remote?()
click to toggle source
# File lib/pxcbackup/backup.rb, line 55 def remote? @repo.is_a? RemoteRepo end
stream()
click to toggle source
# File lib/pxcbackup/backup.rb, line 39 def stream match[:stream].to_sym end
stream_command()
click to toggle source
# File lib/pxcbackup/backup.rb, line 63 def stream_command @repo.stream_command(self) end
time()
click to toggle source
# File lib/pxcbackup/backup.rb, line 29 def time Time.at(match[:timestamp].to_i) end
to_s()
click to toggle source
# File lib/pxcbackup/backup.rb, line 25 def to_s "#{time} - #{type.to_s[0..3]} (#{remote? ? 'remote' : 'local'})" end
type()
click to toggle source
# File lib/pxcbackup/backup.rb, line 33 def type type = match[:type] type = 'incremental' if type == 'incr' type.to_sym end
Private Instance Methods
match()
click to toggle source
# File lib/pxcbackup/backup.rb, line 69 def match match = self.class.regexp.match(@path) return nil unless match { :timestamp => match[1], :type => match[2], :stream => match[3], :encrypted => !!match[4], } end