lib/fulmar/infrastructure/service/database/database_service.rb in fulmar-1.8.5 vs lib/fulmar/infrastructure/service/database/database_service.rb in fulmar-1.8.6

- old
+ new

@@ -72,21 +72,27 @@ connect unless connected? @client.query "CREATE DATABASE IF NOT EXISTS `#{name}`" disconnect unless state_before end + def command(binary) + command = binary + command << " -h #{@config[:maria][:host]}" unless @config[:maria][:host].blank? + command << " -u #{@config[:maria][:user]}" unless @config[:maria][:user].blank? + command << " --password='#{@config[:maria][:password]}'" unless @config[:maria][:password].blank? + command + end + def dump(filename = backup_filename) filename = "#{@config[:remote_path]}/#{filename}" unless filename[0, 1] == '/' - @shell.run "mysqldump -h #{@config[:maria][:host]} -u #{@config[:maria][:user]} --password='#{@config[:maria][:password]}' " \ - "#{@config[:maria][:database]} --single-transaction #{diffable} #{ignore_tables} -r \"#{filename}\"" + @shell.run "#{command('mysqldump')} #{@config[:maria][:database]} --single-transaction #{diffable} #{ignore_tables} -r \"#{filename}\"" filename end def load_dump(dump_file, database = @config[:maria][:database]) - @shell.run "mysql -h #{@config[:maria][:host]} -u #{@config[:maria][:user]} --password='#{@config[:maria][:password]}' " \ - "-D #{database} < #{dump_file}" + @shell.run "#{command('mysql')} -D #{database} < #{dump_file}" end def download_dump(filename = backup_filename) local_path = filename[0, 1] == '/' ? filename : @config[:local_path] + '/' + filename remote_path = dump