Methods

Class/Module Index [+]

Quicksearch

Backup::Database::MySQL

Attributes

additional_options[RW]

Additional “mysqldump” or “innobackupex (backup creation)” options

backup_engine[RW]

Default is :mysqldump (which is built in MySQL and generates a textual SQL file), but can be changed to :innobackupex, which has more feasible restore times for large databases. See: www.percona.com/doc/percona-xtrabackup/

host[RW]

Connectivity options

name[RW]

Name of the database that needs to get dumped To dump all databases, set this to `:all` or leave blank.

only_tables[RW]

Tables to dump. This in only valid if `name` is specified. If none are given, the entire database will be dumped.

password[RW]

Credentials for the specified database

port[RW]

Connectivity options

prepare_options[RW]

Additional innobackupex log preparation phase (“apply-logs”) options

skip_tables[RW]

Tables to skip while dumping the database

If `name` is set to :all (or not specified), these must include a database name. e.g. ‘name.table’. If `name` is given, these may simply be table names.

socket[RW]

Connectivity options

sudo_user[RW]

If set the backup engine command block is executed as the given user

username[RW]

Credentials for the specified database

verbose[RW]

If set, do not suppress innobackupdb output (useful for debugging)

Public Class Methods

new(model, database_id = nil, &block) click to toggle source
# File lib/backup/database/mysql.rb, line 56
def initialize(model, database_id = nil, &block)
  super
  instance_eval(&block) if block_given?

  @name ||= :all
  @backup_engine ||= :mysqldump
end

Public Instance Methods

perform!() click to toggle source

Performs the mysqldump or innobackupex command and outputs the dump file in the dump_path using dump_filename.

<trigger>/databases/MySQL[-<database_id>].[sql|tar][.gz]
# File lib/backup/database/mysql.rb, line 69
def perform!
  super

  pipeline = Pipeline.new
  dump_ext = sql_backup? ? 'sql' : 'tar'

  pipeline << sudo_option(sql_backup? ? mysqldump : innobackupex)

  model.compressor.compress_with do |command, ext|
    pipeline << command
    dump_ext << ext
  end if model.compressor

  pipeline << "#{ utility(:cat) } > " +
      "'#{ File.join(dump_path, dump_filename) }.#{ dump_ext }'"

  pipeline.run
  if pipeline.success?
    log!(:finished)
  else
    raise Error, "Dump Failed!\n" + pipeline.error_messages
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.