Class: Bosh::Director::DbBackup::Adapter::Mysql2

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/db_backup/adapter/mysql2.rb

Instance Method Summary collapse

Constructor Details

#initialize(db_config) ⇒ Mysql2

Returns a new instance of Mysql2.



8
9
10
# File 'lib/bosh/director/db_backup/adapter/mysql2.rb', line 8

def initialize(db_config)
  @db_config = db_config
end

Instance Method Details

#export(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bosh/director/db_backup/adapter/mysql2.rb', line 12

def export(path)
  out, err, status = Open3.capture3({'MYSQL_PWD' => @db_config.fetch('password')},
                                    'mysqldump',
                                    '--user',        @db_config.fetch('user'),
                                    '--host',        @db_config.fetch('host'),
                                    '--port',        @db_config.fetch('port').to_s,
                                    '--result-file', path,
                                    @db_config.fetch('database'))
  raise("mysqldump exited #{status.exitstatus}, output: '#{out}', error: '#{err}'") unless status.success?
  path
end