Class: Siba::Source::MongoDb::Init

Inherits:
Object
  • Object
show all
Includes:
LoggerPlug
Defined in:
lib/siba-source-mongo-db/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Init

Returns a new instance of Init.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/siba-source-mongo-db/init.rb', line 11

def initialize(options)
  host = Siba::SibaCheck.options_string options, "host", true
  username = Siba::SibaCheck.options_string options, "username", true
  password = Siba::SibaCheck.options_string options, "password", true
  database = Siba::SibaCheck.options_string options, "database", true
  collection = Siba::SibaCheck.options_string options, "collection", true
  @db = Siba::Source::MongoDb::Db.new({
    host: host, 
    username: username, 
    password: password, 
    database: database, 
    collection: collection})
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



9
10
11
# File 'lib/siba-source-mongo-db/init.rb', line 9

def db
  @db
end

Instance Method Details

#backup(dest_dir) ⇒ Object

Collect source files and put them into dest_dir No return value is expected



27
28
29
30
# File 'lib/siba-source-mongo-db/init.rb', line 27

def backup(dest_dir)
  logger.info "Dumping MongoDb#{db.db_and_collection_names}"
  @db.backup dest_dir
end

#restore(from_dir) ⇒ Object

Restore source files from_dir No return value is expected



34
35
36
37
# File 'lib/siba-source-mongo-db/init.rb', line 34

def restore(from_dir)
  logger.info "Restoring MongoDb#{db.db_and_collection_names}"
  @db.restore from_dir
end