Class: MysqlBackup::Entity::Files::Innodb
- Inherits:
-
MysqlBackup::Entity::Files
- Object
- MysqlBackup::Entity
- MysqlBackup::Entity::Files
- MysqlBackup::Entity::Files::Innodb
- Defined in:
- lib/mysql_backup/entity/files/innodb.rb
Overview
Used to save all of the files for a MySQL Innodb 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
-
Innodb data files. Your innodb files must all start with the same string and end with a sequence of digits.
ibdata001
,ibdata002
, etc. is fine, butfirstfile
,secondfile
is not supported. -
MyISAM files.
-
Log files. You need to specify the directory where the log files are stored; there’s no way to extract this from a running server.
-
mysqladmindump
files.
For all of these, we track the log positions (the log file/log position pair).
Instance Attribute Summary collapse
-
#datadir ⇒ Object
Returns the value of attribute datadir.
-
#innodb_data_file_path ⇒ Object
Returns the value of attribute innodb_data_file_path.
-
#innodb_data_home_dir ⇒ Object
Returns the value of attribute innodb_data_home_dir.
Attributes inherited from MysqlBackup::Entity
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Innodb
constructor
Takes the following arguments:.
-
#innodb_database_dirs ⇒ Object
Returns an array of Pathnames for all databases in the base directory.
- #innodb_files ⇒ Object
-
#required_paths ⇒ Object
Returns a list of Pathname objects that need to be backed up for a mysql server using innodb.
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
Constructor Details
#initialize(args = {}) ⇒ Innodb
Takes the following arguments:
:datadir => The MySQL data directory.
:innodb_data_home_dir => The directory for innodb files.
:innodb_data_file_path => The root name for the innodb files.
:log_bin_dir => The directory containing the log files.
:log_bin => The prefix of the log files.
The following files will be backed up with the default base_dir and ib_basename:
/var/lib/mysql/ibdata*
/var/lib/mysql/*/*.frm - all files in any directory that contain one or more *.frm files
/var/lib/mysql/*/*.MYD - all files in any directory that contain one or more *.MYD files
49 50 51 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 49 def initialize args = {} set_path_vars %w(datadir innodb_data_home_dir), args end |
Instance Attribute Details
#datadir ⇒ Object
Returns the value of attribute datadir.
34 35 36 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 34 def datadir @datadir end |
#innodb_data_file_path ⇒ Object
Returns the value of attribute innodb_data_file_path.
34 35 36 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 34 def innodb_data_file_path @innodb_data_file_path end |
#innodb_data_home_dir ⇒ Object
Returns the value of attribute innodb_data_home_dir.
34 35 36 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 34 def innodb_data_home_dir @innodb_data_home_dir end |
Instance Method Details
#innodb_database_dirs ⇒ Object
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.
67 68 69 70 71 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 67 def innodb_database_dirs result = Pathname.glob(@innodb_data_home_dir_path + '*/*.frm') result = result.map {|d| d.dirname} result.uniq end |
#innodb_files ⇒ Object
73 74 75 76 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 73 def innodb_files ib = @innodb_data_home_dir_path + @innodb_data_file_path Pathname.glob ib.cleanpath.to_s + '*' end |
#required_paths ⇒ Object
Returns a list of Pathname objects that need to be backed up for a mysql server using innodb.
55 56 57 58 59 60 |
# File 'lib/mysql_backup/entity/files/innodb.rb', line 55 def required_paths result = [] result.concat innodb_files result.concat innodb_database_dirs result.uniq end |