class Brillo::Dumper::MysqlDumper

Attributes

config[R]

Public Class Methods

new(config) click to toggle source
# File lib/brillo/dumper/mysql_dumper.rb, line 7
def initialize(config)
  @config = config
end

Public Instance Methods

dump() click to toggle source
# File lib/brillo/dumper/mysql_dumper.rb, line 11
def dump
  db = config.db
  execute!(
    "mysqldump",
    host_arg,
    "-u #{db["username"]}",
    password_arg,
    "--no-data",
    "--single-transaction", # InnoDB only. Prevent MySQL locking the whole database during dump.
    "#{db["database"]}",
    "> #{config.dump_path}"
  )
end

Private Instance Methods

host_arg() click to toggle source
# File lib/brillo/dumper/mysql_dumper.rb, line 35
def host_arg
  if (host = config.db["host"].presence) && host != 'localhost'
    "-h #{host}"
  else
    ""
  end
end
password_arg() click to toggle source
# File lib/brillo/dumper/mysql_dumper.rb, line 27
def password_arg
  if password = config.db["password"].presence
    "--password=#{password}"
  else
    ""
  end
end