class StellarCoreBackup::Restore::Database

Attributes

dbname[R]

Public Class Methods

new(config) click to toggle source
# File lib/stellar-core-backup/restore/database.rb, line 10
def initialize(config)
  @config       = config
  @working_dir  = StellarCoreBackup::Utils.create_working_dir(@config.get('working_dir'))
  @dbname       = check_db_connection
  @cmd          = StellarCoreBackup::Cmd.new(@working_dir)
end

Public Instance Methods

restore() click to toggle source
# File lib/stellar-core-backup/restore/database.rb, line 19
def restore()
  puts "info: database restored" if pg_restore()
end

Private Instance Methods

pg_restore() click to toggle source
# File lib/stellar-core-backup/restore/database.rb, line 25
def pg_restore()
  # we are restoring to public schema
  pg_restore = @cmd.run('pg_restore', ['-n', 'public', '--jobs', "#{StellarCoreBackup::Utils.num_cores?()}", '-c', '-d', @dbname, 'core-db/'])
  if pg_restore.success then
    return true
  else
    return false
  end
end