class StellarCoreBackup::Restore::Filesystem

Attributes

core_data_dir[R]

Public Class Methods

new(config) click to toggle source
# File lib/stellar-core-backup/restore/filesystem.rb, line 10
def initialize(config)
  @config         = config
  @working_dir    = StellarCoreBackup::Utils.create_working_dir(@config.get('working_dir'))
  @core_data_dir  = get_core_data_dir(@config.get('core_config'))
end

Public Instance Methods

core_data_dir_empty?() click to toggle source
# File lib/stellar-core-backup/restore/filesystem.rb, line 25
def core_data_dir_empty?()
  # checks fs and asks user to remove fs manually if fs is already in place.
  if (Dir.entries(@core_data_dir) - %w{ . .. }).empty? then
    return true
  else
    puts "error: #{@core_data_dir} is not empty, you can only restore to an empty data directory"
    raise DataDirNotEmpty
  end
end
restore(backup_archive) click to toggle source
# File lib/stellar-core-backup/restore/filesystem.rb, line 19
def restore(backup_archive)
  # unpack the filesystem backup
  puts "info: stellar-core buckets restored" if StellarCoreBackup::Tar.unpack("#{@working_dir}/core-fs.tar", @core_data_dir)
end