Class: Brillo::Dumper::MysqlDumper

Inherits:
Object
  • Object
show all
Includes:
Helpers::ExecHelper, Logger
Defined in:
lib/brillo/dumper/mysql_dumper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger, logger, logger=

Methods included from Helpers::ExecHelper

#execute, #execute!

Constructor Details

#initialize(config) ⇒ MysqlDumper

Returns a new instance of MysqlDumper.



7
8
9
# File 'lib/brillo/dumper/mysql_dumper.rb', line 7

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/brillo/dumper/mysql_dumper.rb', line 6

def config
  @config
end

Instance Method Details

#dumpObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# 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