Class: MysqlBackup::Entity::Logs

Inherits:
Files show all
Includes:
NamedArguments
Defined in:
lib/mysql_backup/entity/logs.rb

Instance Attribute Summary collapse

Attributes inherited from MysqlBackup::Entity

#log

Instance Method Summary collapse

Methods inherited from Files

build_files, #confirm_required_paths_are_readable, create_tar_files, do_tar, process_file, #required_path_strings, #set_path_vars

Methods inherited from MysqlBackup::Entity

tar_files

Constructor Details

#initialize(args = {}) ⇒ Logs

Takes the following arguments:

:log_bin_dir => The prefix of the log files
:completed_logs => All the logs before the one being written
:log_file => The current log
:log_position => The position in the log file


19
20
21
22
# File 'lib/mysql_backup/entity/logs.rb', line 19

def initialize args = {}
  super
  @log_bin_dir = Pathname.new(args[:log_bin_dir])
end

Instance Attribute Details

#completed_logsObject

Returns the value of attribute completed_logs.



9
10
11
# File 'lib/mysql_backup/entity/logs.rb', line 9

def completed_logs
  @completed_logs
end

#log_bin_dirObject

Returns the value of attribute log_bin_dir.



8
9
10
# File 'lib/mysql_backup/entity/logs.rb', line 8

def log_bin_dir
  @log_bin_dir
end

#log_fileObject

Returns the value of attribute log_file.



11
12
13
# File 'lib/mysql_backup/entity/logs.rb', line 11

def log_file
  @log_file
end

#log_positionObject

Returns the value of attribute log_position.



10
11
12
# File 'lib/mysql_backup/entity/logs.rb', line 10

def log_position
  @log_position
end

Instance Method Details

#completed_logs_pathsObject



24
25
26
# File 'lib/mysql_backup/entity/logs.rb', line 24

def completed_logs_paths
  completed_logs.map {|l| Pathname.new(log_bin_dir) + l}
end

#log_file_pathObject



28
29
30
# File 'lib/mysql_backup/entity/logs.rb', line 28

def log_file_path
  Pathname.new(log_bin_dir) + log_file
end

#save(args = {}) {|:identifier => i, :file => log_file_path| ... } ⇒ Object

Yields:



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mysql_backup/entity/logs.rb', line 32

def save args = {}
  # Do the complete logs
  completed_logs_paths.each do |p|
    i = MysqlBackup::Entity::Identifier.create_object :category => :log, :type => :complete, :log_file => p.basename.to_s, :n_parts => 1, :part_number => 0
    files = self.class.tar_files [p.to_s]
    yield :identifier => i, :file => files.first
  end
  
  # Do the current log
  i = MysqlBackup::Entity::Identifier.create_object :category => :log, :type => :current, :log_file => log_file, :log_position => log_position, :n_parts => 1, :part_number => 0
  yield :identifier => i, :file => log_file_path
end