class Dumpr::Driver::Mysql
Public Instance Methods
configure(opts)
click to toggle source
Calls superclass method
Dumpr::Driver::Base#configure
# 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_cmd()
click to toggle source
# 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?()
click to toggle source
# File lib/dumpr/driver/mysql.rb, line 14 def dump_installed? system("which mysqldump") == true end
dump_options()
click to toggle source
# File lib/dumpr/driver/mysql.rb, line 10 def dump_options @dump_options || "--single-transaction --quick" end
import_cmd()
click to toggle source
# File lib/dumpr/driver/mysql.rb, line 45 def import_cmd #"mysql -u #{user} --password=#{password} -h #{host} -P #{port} #{database} < #{dumpfile}" cmd = ["mysql"] cmd << "-u '#{user}'" unless user.to_s.empty? cmd << "--password '#{password}'" unless password.to_s.empty? cmd << "-h '#{host}'" unless host.to_s.empty? cmd << "-P '#{port}'" unless port.to_s.empty? cmd << "#{database}" unless database.empty? cmd << "#{import_options}" unless import_options.to_s.empty? cmd << " < #{dumpfile}" cmd.join(" ") end
import_installed?()
click to toggle source
# File lib/dumpr/driver/mysql.rb, line 18 def import_installed? system("which mysql") == true end
port()
click to toggle source
# File lib/dumpr/driver/mysql.rb, line 6 def port @port || 3306 end