Class: Dumpr::Driver::Mysql
- Inherits:
-
Base
- Object
- Base
- Dumpr::Driver::Mysql
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?
Instance Method Details
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
elsif @databases
elsif @database
else
raise BadConfig.new "#{self.class} requires option --database or --databases or --all-databases"
end
end
|
#dump_cmd ⇒ Object
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
14
15
16
|
# File 'lib/dumpr/driver/mysql.rb', line 14
def dump_installed?
system("which mysqldump") == true
end
|
#dump_options ⇒ Object
10
11
12
|
# File 'lib/dumpr/driver/mysql.rb', line 10
def dump_options
@dump_options || "--single-transaction --quick"
end
|
#import_cmd ⇒ Object
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
18
19
20
|
# File 'lib/dumpr/driver/mysql.rb', line 18
def import_installed?
system("which mysql") == true
end
|
#port ⇒ Object
6
7
8
|
# File 'lib/dumpr/driver/mysql.rb', line 6
def port
@port || 3306
end
|