Class: Flydata::Mysql::MysqlDumpGeneratorMasterData

Inherits:
MysqlDumpGenerator show all
Defined in:
lib/flydata/command/sync.rb

Constant Summary collapse

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

Constants inherited from MysqlDumpGenerator

Flydata::Mysql::MysqlDumpGenerator::MYSQL_DUMP_CMD_TEMPLATE

Instance Method Summary collapse

Methods inherited from MysqlDumpGenerator

#initialize

Constructor Details

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

Instance Method Details

#dump(file_path) ⇒ Object



853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
# File 'lib/flydata/command/sync.rb', line 853

def dump(file_path)
  cmd = "#{@dump_cmd} > #{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