Class: MongoDbUtils::Tools::Restore

Inherits:
BaseCmd
  • Object
show all
Defined in:
lib/mongo-db-utils/tools/commands.rb

Class Method Summary collapse

Class Method Details

.cmd(host_and_port, db, source_folder, username = "", password = "") ⇒ Object



59
60
61
62
63
# File 'lib/mongo-db-utils/tools/commands.rb', line 59

def self.cmd(host_and_port,db,source_folder,username = "", password = "")
  options = build_base_options(host_and_port,db,username,password)
  params = options_string(options) << " --drop #{source_folder}"
  "mongorestore #{params}"
end

.run(host_and_port, db, source_folder, username = "", password = "") ⇒ Object

Raises:



65
66
67
68
69
70
# File 'lib/mongo-db-utils/tools/commands.rb', line 65

def self.run(host_and_port,db,source_folder,username="", password ="")
  cmd_string = self.cmd(host_and_port,db,source_folder,username,password)
  puts "[Restore] run: #{cmd_string}"
  output = `#{cmd_string}`
  raise ToolsException.new("#{cmd_string}", output) unless $?.to_i == 0
end