Class: Flydata::Parser::Mysql::MysqlDumpGeneratorMasterData

Inherits:
MysqlDumpGenerator show all
Defined in:
lib/flydata/parser/mysql/dump_parser.rb

Constant Summary collapse

EXTRA_MYSQLDUMP_PARAMS =
"--flush-logs --master-data=2"

Constants inherited from MysqlDumpGenerator

Flydata::Parser::Mysql::MysqlDumpGenerator::MYSQL_DUMP_CMD_TEMPLATE

Instance Method Summary collapse

Methods inherited from MysqlDumpGenerator

#initialize

Constructor Details

This class inherits a constructor from Flydata::Parser::Mysql::MysqlDumpGenerator

Instance Method Details

#dump(file_path) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/flydata/parser/mysql/dump_parser.rb', line 62

def dump(file_path)
  cmd = "#{@dump_cmd} -r #{file_path}"
  o, e, s = Open3.capture3(cmd)
  e.to_s.each_line {|l|  puts l unless /^Warning:/ =~ l } unless e.to_s.empty?
  unless s.exitstatus == 0
    if File.exists?(file_path)
      File.open(file_path, 'r') {|f| f.each_line{|l| puts l}}
      FileUtils.rm(file_path)
    end
    raise "Failed to run mysqldump command."
  end
  unless File.exists?(file_path)
    raise "mysqldump file does not exist. Something wrong..."
  end
  if File.size(file_path) == 0
    raise "mysqldump file is empty. Something wrong..."
  end
  true
end