Sha256: 26f8747400ee45841ae81c9afd843e5382fee5925734e03394783d3ee46c74ad

Contents?: true

Size: 916 Bytes

Versions: 16

Compression:

Stored size: 916 Bytes

Contents

module Brillo
  module Dumper
    class MysqlDumper
      include Helpers::ExecHelper
      include Logger
      attr_reader :config
      def initialize(config)
        @config = config
      end

      def dump
        db = config.db
        execute!(
          "mysqldump",
          host_arg,
          "-u #{db[:username]}",
          password_arg,
          "--no-data",
          "--single-transaction", # InnoDB only. Prevent MySQL locking the whole database during dump.
          "#{db[:database]}",
          "> #{config.dump_path}"
        )
      end

      private

      def password_arg
        if password = config.db[:password].presence
          "--password=#{password}"
        else
          ""
        end
      end

      def host_arg
        if (host = config.db[:host].presence) && host != 'localhost'
          "-h #{host}"
        else
          ""
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
brillo-2.0.0.rc2 lib/brillo/dumper/mysql_dumper.rb
brillo-2.0.0.rc1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.3.1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.3.1.pre1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.3.0 lib/brillo/dumper/mysql_dumper.rb
brillo-1.2.2 lib/brillo/dumper/mysql_dumper.rb
brillo-1.2.1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.2.0 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.4 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.4.pre2 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.4.pre1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.3 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.2 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.1 lib/brillo/dumper/mysql_dumper.rb
brillo-1.1.0 lib/brillo/dumper/mysql_dumper.rb
brillo-1.0.0 lib/brillo/dumper/mysql_dumper.rb