class Bosh::Director::Api::RestoreManager

Public Class Methods

new() click to toggle source
# File lib/bosh/director/api/restore_manager.rb, line 4
def initialize
  @logger = Config.logger
  @db_config = Config.db_config
end

Public Instance Methods

restore_db(path) click to toggle source
# File lib/bosh/director/api/restore_manager.rb, line 9
def restore_db(path)
  @logger.debug("Restoring database from db_dump file: #{path}...")

  db_name = @db_config.fetch('database')
  adapter = @db_config.fetch('adapter')
  user = @db_config.fetch('user')
  pass = @db_config.fetch('password')
  host = @db_config.fetch('host')

  Process.spawn(
    'sudo',
    "LD_LIBRARY_PATH=#{ENV['LD_LIBRARY_PATH']}",
    'restore-db',
    adapter,
    host,
    user,
    pass,
    db_name,
    path,
    out: '/dev/null'
  )
end