Class: MysqlBackup::Entity
- Inherits:
-
Object
- Object
- MysqlBackup::Entity
- Defined in:
- lib/mysql_backup/entity.rb,
lib/mysql_backup/entity/identifier.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Files, Identifier, Logs, Mysqldump
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
Class Method Summary collapse
-
.tar_files(path_strings) ⇒ Object
Create a set of tarred, gziped, and split files for all the files given by required_path_strings.
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
10 11 12 |
# File 'lib/mysql_backup/entity.rb', line 10 def log @log end |
Class Method Details
.tar_files(path_strings) ⇒ Object
Create a set of tarred, gziped, and split files for all the files given by required_path_strings.
Return an array of Pathname objects for the split files.
The caller is responsible for removing the files returned from tar_files.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mysql_backup/entity.rb', line 20 def self.tar_files path_strings #:nodoc: result = [] # Creating a tempfile to get a guaranteed unique filename. # We don't actually write to this tempfile, we just # use its name as the base name for the split. Tempfile.open 'mysqltarball' do |f| # We should never see existing files, but just in # case we'll need to remove any. Pathname.glob(f.path.to_s + 'xxx*').each {|e| e.unlink} paths = path_strings.map {|ps| ps.slice(1..-1)}.join(' ') five_gig = 1024 * 1024 * 1024 * 5 tar_cmd = "( cd / ; tar cf - #{paths} | gzip | split --suffix-length=4 --bytes=#{five_gig} --numeric-suffixes - #{f.path}xxx )" do_tar :cmd => tar_cmd result = Pathname.glob(f.path.to_s + 'xxx*') end result end |