Class: MysqlBackup::Entity::Files::Myisam

Inherits:
MysqlBackup::Entity::Files show all
Defined in:
lib/mysql_backup/entity/files/myisam.rb

Overview

Used to save all of the files for a MySQL MyISAM database.

Normal use is:

i = Mysql::InnodbFiles.new
array_of_pathname_objects = i.tar_files

The caller is responsible for removing the files returned from tar_files.

See new for a description of the arguments used to create a Mysql::InnodbFiles object matching your mysql layout.

You can create instances of Mysql::InnodbFiles by hand, but normally you’d use MysqlBackup::Server to create them for you.

MysqlBackup::Server objects will detect where your data files are and fill in the correct options for Mysql::InnodbFiles.new.

What is backed up

  • MyISAM files.

For all of these, we track the log positions (the log file/log position pair).

Instance Attribute Summary collapse

Attributes inherited from MysqlBackup::Entity

#log

Instance Method Summary collapse

Methods inherited from MysqlBackup::Entity::Files

build_files, #confirm_required_paths_are_readable, create_tar_files, do_tar, process_file, #required_path_strings, #set_path_vars

Methods inherited from MysqlBackup::Entity

tar_files

Constructor Details

#initialize(args = {}) ⇒ Myisam

Returns a new instance of Myisam.



38
39
40
41
# File 'lib/mysql_backup/entity/files/myisam.rb', line 38

def initialize args = {}
  super
  set_path_vars %w(datadir), args
end

Instance Attribute Details

#datadirObject

Takes the following arguments:

:datadir => The MySQL data directory.

The following files will be backed up with the default base_dir and ib_basename:

/var/lib/mysql/*/*.MYD - all files in any directory that contain one or more *.MYD files


36
37
38
# File 'lib/mysql_backup/entity/files/myisam.rb', line 36

def datadir
  @datadir
end

Instance Method Details

#myisam_database_dirsObject

Returns an array of Pathnames for all databases in the base directory.

A database in this case is a directory containing any files matching *.frm.



56
57
58
59
60
61
# File 'lib/mysql_backup/entity/files/myisam.rb', line 56

def myisam_database_dirs
  result = Pathname.glob(@datadir_path + '*/*.MYD')
  result.concat Pathname.glob(@datadir_path + '*/*.MYI')
  result = result.map {|d| d.dirname}
  result.uniq
end

#required_pathsObject

Returns a list of Pathname objects that need to be backed up for a mysql server using innodb.



45
46
47
48
49
# File 'lib/mysql_backup/entity/files/myisam.rb', line 45

def required_paths
  result = []
  result.concat myisam_database_dirs
  result.uniq
end