Class: Siba::Archive::Tar::Init

Inherits:
Object
  • Object
show all
Includes:
LoggerPlug
Defined in:
lib/siba/plugins/archive/tar/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoggerPlug

close, create, logger, #logger, opened?

Constructor Details

#initialize(options) ⇒ Init

Returns a new instance of Init.



15
16
17
18
19
20
# File 'lib/siba/plugins/archive/tar/init.rb', line 15

def initialize(options)
  options = options
  compression = Siba::SibaCheck.options_string options, "compression", true, DefaultCompression
  Archive.check_compression_type compression
  @archive = Archive.new compression
end

Instance Attribute Details

#archiveObject

Returns the value of attribute archive.



13
14
15
# File 'lib/siba/plugins/archive/tar/init.rb', line 13

def archive
  @archive
end

Instance Method Details

#backup(sources_dir, dest_dir, dest_file_name) ⇒ Object

Archive the contents of sources_dir and put it to dest_dir. Return the archive file name. It must start with dest_file_name and its ending must not vary with time.



25
26
27
28
# File 'lib/siba/plugins/archive/tar/init.rb', line 25

def backup(sources_dir, dest_dir, dest_file_name)
  logger.info "Archiving with 'tar', compression: '#{archive.compression}'"
  @archive.archive sources_dir, dest_dir, dest_file_name
end

#restore(path_to_archive, to_dir) ⇒ Object

Extract archive file (path_to_archive) to_dir No return value is expected.



32
33
34
35
# File 'lib/siba/plugins/archive/tar/init.rb', line 32

def restore(path_to_archive, to_dir)
  logger.info "Extracting 'tar' archive, compression: '#{archive.compression}'"
  @archive.extract path_to_archive, to_dir
end