Class: Mongo::MongoClient
- Inherits:
-
Object
- Object
- Mongo::MongoClient
- Defined in:
- lib/mongolly/extensions/mongo/mongo_client.rb
Constant Summary collapse
- MAX_DISABLE_BALANCER_WAIT =
8 Minutes
60 * 8
- MAX_UNLOCK_RETRIES =
3
- UNLOCK_SLEEP =
10 Seconds
10
- REPLICA_SNAPSHOT_THRESHOLD =
5 Minutes
60 * 5
- REPLICA_SNAPSHOT_PREFER_HIDDEN =
true
- DEFAULT_MONGO_PORT =
rubocop: disable Style/NumericLiterals
27017
Instance Method Summary collapse
Instance Method Details
#snapshot_ebs(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mongolly/extensions/mongo/mongo_client.rb', line 23 def snapshot_ebs( = {}) @mongolly_dry_run = [:dry_run] || false @mongolly_logger = [:logger] || Logger.new(STDOUT) [:volume_tag] ||= "mongolly" [:backup_key] ||= (0...8).map { 65.+(rand(25)).chr }.join @ec2 = AWS::EC2.new(access_key_id: [:access_key_id], secret_access_key: [:secret_access_key], region: [:region]) if mongos? @mongolly_logger.info("Detected sharded cluster") with_disabled_balancing do with_config_server_stopped() do backup_instance(config_server, ) shards.each do |name, hosts| @mongolly_logger.debug("Found Shard #{name} with hosts #{hosts}.") replica_set_connection(hosts, ).snapshot_ebs() end end end else backup_instance(snapshot_ebs_target(REPLICA_SNAPSHOT_THRESHOLD, REPLICA_SNAPSHOT_PREFER_HIDDEN), .merge(strict_connection: true)) end end |