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.
52 53 54 55 |
# File 'lib/backup/database/mongodb.rb', line 52 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
30 31 32 |
# File 'lib/backup/database/mongodb.rb', line 30 def @additional_options end |
#authdb ⇒ Object
Credentials for the specified database
14 15 16 |
# File 'lib/backup/database/mongodb.rb', line 14 def authdb @authdb end |
#host ⇒ Object
Connectivity options
18 19 20 |
# File 'lib/backup/database/mongodb.rb', line 18 def host @host end |
#ipv6 ⇒ Object
IPv6 support (disabled by default)
22 23 24 |
# File 'lib/backup/database/mongodb.rb', line 22 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.
39 40 41 |
# File 'lib/backup/database/mongodb.rb', line 39 def lock @lock end |
#name ⇒ Object
Name of the database that needs to get dumped
10 11 12 |
# File 'lib/backup/database/mongodb.rb', line 10 def name @name end |
#only_collections ⇒ Object
Collections to dump, collections that aren’t specified won’t get dumped
26 27 28 |
# File 'lib/backup/database/mongodb.rb', line 26 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.
50 51 52 |
# File 'lib/backup/database/mongodb.rb', line 50 def oplog @oplog end |
#password ⇒ Object
Credentials for the specified database
14 15 16 |
# File 'lib/backup/database/mongodb.rb', line 14 def password @password end |
#port ⇒ Object
Connectivity options
18 19 20 |
# File 'lib/backup/database/mongodb.rb', line 18 def port @port end |
#username ⇒ Object
Credentials for the specified database
14 15 16 |
# File 'lib/backup/database/mongodb.rb', line 14 def username @username end |
Instance Method Details
#perform! ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/backup/database/mongodb.rb', line 57 def perform! super lock_database if @lock dump! package! ensure unlock_database if @lock end |