Class: Monsoon::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/monsoon/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket = Monsoon.bucket, key = Monsoon.key, secret = Monsoon.secret, mongo_uri = Monsoon.mongo_uri) ⇒ Client

Returns a new instance of Client.



4
5
6
7
8
9
# File 'lib/monsoon/client.rb', line 4

def initialize(bucket = Monsoon.bucket, key = Monsoon.key, secret = Monsoon.secret, mongo_uri = Monsoon.mongo_uri)
  @bucket           = bucket
  @key              = key
  @secret           = secret
  @mongo_uri        = mongo_uri
end

Instance Method Details

#backupObject

Creates an instance of the Monsoon::Backup class

Examples

Monsoon::Client.new.backup
# => #<Monsoon::Backup>

Returns an instance of the Monsoon::Client object



43
44
45
# File 'lib/monsoon/client.rb', line 43

def backup
  Backup.new(@mongo_uri)
end

#compress(backup) ⇒ Object

Creates an instnace of the Monsoon::Compress class

backup - The Monsoon::Backup instance the preceeded.

Examples

Monsoon::Client.new.compress(#<Monsoon::Backup>)
# => #<Monsoon::Compress>

Returns an instance of the Monsoon::Compress object



57
58
59
# File 'lib/monsoon/client.rb', line 57

def compress(backup)
  Compress.new(backup)
end

#runObject

Run the Monsoon process to backup, save, and clean the work.

Examples

Monsoon::Client.new.run
# => True

Returns True



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/monsoon/client.rb', line 19

def run
  # Backup the MongoDB database to filesystem
  b = backup.run
  
  # Compress the contents of the backup
  c = compress(b).run
  
  # Sent to AWS
  store(c.filename).save

  # Remove the compressed file from the filesystem
  c.clean

  true
end

#store(filename) ⇒ Object

Creates an instance of the Monsoon::Store class

filename - The String filename of the compressed backup to push to S3.

Examples

Monsoon::Client.new.store("test.tar.gz")
# => #<Monsoon::Store>

Returns an instance of the Monsoon::Store object



71
72
73
# File 'lib/monsoon/client.rb', line 71

def store(filename)
  Store.new(filename, @bucket, @key, @secret)
end