Class: Backup::Database::MongoDB
- Defined in:
- lib/backup/database/mongodb.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#additional_options ⇒ Object
Additional “mongodump” options.
-
#authdb ⇒ Object
Credentials for the specified database.
-
#host ⇒ Object
Connectivity options.
-
#ipv6 ⇒ Object
IPv6 support (disabled by default).
-
#lock ⇒ Object
Forces mongod to flush all pending write operations to the disk and locks the entire mongod instance to prevent additional writes until the dump is complete.
-
#name ⇒ Object
Name of the database that needs to get dumped.
-
#only_collections ⇒ Object
Collections to dump, collections that aren’t specified won’t get dumped.
-
#oplog ⇒ Object
Creates a dump of the database that includes an oplog, to create a point-in-time snapshot of the state of a mongod instance.
-
#password ⇒ Object
Credentials for the specified database.
-
#port ⇒ Object
Connectivity options.
-
#username ⇒ Object
Credentials for the specified database.
Attributes inherited from Base
#database_id, #dump_path, #model
Instance Method Summary collapse
-
#initialize(model, database_id = nil, &block) ⇒ MongoDB
constructor
A new instance of MongoDB.
- #perform! ⇒ Object
Methods included from Config::Helpers
Constructor Details
#initialize(model, database_id = nil, &block) ⇒ MongoDB
Returns a new instance of MongoDB.
50 51 52 53 |
# File 'lib/backup/database/mongodb.rb', line 50 def initialize(model, database_id = nil, &block) super instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#additional_options ⇒ Object
Additional “mongodump” options
28 29 30 |
# File 'lib/backup/database/mongodb.rb', line 28 def @additional_options end |
#authdb ⇒ Object
Credentials for the specified database
12 13 14 |
# File 'lib/backup/database/mongodb.rb', line 12 def authdb @authdb end |
#host ⇒ Object
Connectivity options
16 17 18 |
# File 'lib/backup/database/mongodb.rb', line 16 def host @host end |
#ipv6 ⇒ Object
IPv6 support (disabled by default)
20 21 22 |
# File 'lib/backup/database/mongodb.rb', line 20 def ipv6 @ipv6 end |
#lock ⇒ Object
Forces mongod to flush all pending write operations to the disk and locks the entire mongod instance to prevent additional writes until the dump is complete.
Note that if Profiling is enabled, this will disable it and will not re-enable it after the dump is complete.
37 38 39 |
# File 'lib/backup/database/mongodb.rb', line 37 def lock @lock end |
#name ⇒ Object
Name of the database that needs to get dumped
8 9 10 |
# File 'lib/backup/database/mongodb.rb', line 8 def name @name end |
#only_collections ⇒ Object
Collections to dump, collections that aren’t specified won’t get dumped
24 25 26 |
# File 'lib/backup/database/mongodb.rb', line 24 def only_collections @only_collections end |
#oplog ⇒ Object
Creates a dump of the database that includes an oplog, to create a point-in-time snapshot of the state of a mongod instance.
If this option is used, you would not use the ‘lock` option.
This will only work against nodes that maintain a oplog. This includes all members of a replica set, as well as master nodes in master/slave replication deployments.
48 49 50 |
# File 'lib/backup/database/mongodb.rb', line 48 def oplog @oplog end |
#password ⇒ Object
Credentials for the specified database
12 13 14 |
# File 'lib/backup/database/mongodb.rb', line 12 def password @password end |
#port ⇒ Object
Connectivity options
16 17 18 |
# File 'lib/backup/database/mongodb.rb', line 16 def port @port end |
#username ⇒ Object
Credentials for the specified database
12 13 14 |
# File 'lib/backup/database/mongodb.rb', line 12 def username @username end |
Instance Method Details
#perform! ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/backup/database/mongodb.rb', line 55 def perform! super lock_database if @lock dump! package! ensure unlock_database if @lock end |