Class: StellarCoreBackup::Tar

Inherits:
Object
  • Object
show all
Includes:
Contracts
Defined in:
lib/stellar-core-backup/tar.rb

Class Method Summary collapse

Class Method Details

.pack(archive, directory) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stellar-core-backup/tar.rb', line 8

def self.pack(archive, directory)
  if StellarCoreBackup::Utils.readable?(directory) then
    # archive directory
    puts "info: packing #{directory} in #{archive}"
    %x{/bin/tar --create --file=#{archive} #{directory}}
    if $?.exitstatus == 0 then
      puts "info: #{archive} created"
      return archive
    else
      raise StandardError
    end
  end
end

.unpack(archive, destination) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stellar-core-backup/tar.rb', line 23

def self.unpack(archive, destination)
  if StellarCoreBackup::Utils.writable?(destination) then
    # extract archive in destination directory
    puts "info: unpacking #{archive} in #{destination}"
    %x{/bin/tar --extract --file=#{archive} --directory=#{destination}}
    if $?.exitstatus == 0 then
      puts "info: #{archive} unpacked in #{destination}"
      return destination
    else
      raise StandardError
    end
  end
end