Class: Dumpr::Driver::Mysql

Inherits:
Base
  • Object
show all
Defined in:
lib/dumpr/driver/mysql.rb

Instance Attribute Summary

Attributes inherited from Base

#database, #destination, #destination_dumpfile, #destination_host, #dumpdir, #dumpfile, #gzip, #gzip_options, #host, #import_options, #opts, #password, #tables, #user

Instance Method Summary collapse

Methods inherited from Base

#decompress, #dump, #import, #initialize, #logger, #remote_destination?

Constructor Details

This class inherits a constructor from Dumpr::Driver::Base

Instance Method Details

#configure(opts) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dumpr/driver/mysql.rb', line 22

def configure(opts)
  super(opts)
  if @all_databases
    # supported
  elsif @databases
    # supported
  elsif @database
    # supported
  else
    raise BadConfig.new "#{self.class} requires option --database or --databases or --all-databases"
  end
end

#dump_cmdObject



35
36
37
38
39
40
41
42
43
# File 'lib/dumpr/driver/mysql.rb', line 35

def dump_cmd
  if @all_databases
    "mysqldump -u #{user} --password=#{password} -h #{host} -P #{port} --all-databases #{dump_options}"
  elsif @databases
    "mysqldump -u #{user} --password=#{password} -h #{host} -P #{port} --databases #{databases.join(' ')} #{dump_options}"
  else
    "mysqldump -u #{user} --password=#{password} -h #{host} -P #{port} #{database} #{tables ? tables.join(' ') : ''} #{dump_options}"
  end
end

#dump_installed?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dumpr/driver/mysql.rb', line 14

def dump_installed?
  system("which mysqldump") == true
end

#dump_optionsObject



10
11
12
# File 'lib/dumpr/driver/mysql.rb', line 10

def dump_options
  @dump_options || "--single-transaction --quick"
end

#import_cmdObject



45
46
47
# File 'lib/dumpr/driver/mysql.rb', line 45

def import_cmd
  "mysql -u #{user} --password=#{password} -h #{host} -P #{port} #{database} < #{dumpfile}"
end

#import_installed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dumpr/driver/mysql.rb', line 18

def import_installed?
  system("which mysql") == true
end

#portObject



6
7
8
# File 'lib/dumpr/driver/mysql.rb', line 6

def port
  @port || 3306
end