mondupe 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/mondupe +2 -2
- data/lib/mondupe.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28272fa761a894d66603c535701b92dedf61b015
|
4
|
+
data.tar.gz: 6421d1c37d0252b30db1bfff113da6ceb44e849c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb1b052009843d80149d582718f3f2ad4cc9436c7698b209be75607cf461d88cd7c36887f99558ac8785eaad21603f19e3356ae750af8c660f61b87a95f307c3
|
7
|
+
data.tar.gz: 59ff7db8618ef03104be1296e699d0ce3959922132c42f598fb52d5c973423c5d9eb6694df0160d1eb1444b45a678024e1a53dadc93c25967bd469e680dedb51
|
data/bin/mondupe
CHANGED
@@ -159,7 +159,7 @@ when "create"
|
|
159
159
|
instance = Mondupe.new.create_instance(instance_name, instance_image_id, instance_type, instance_count, security_group, key_pair_name, expire_days, instance_owner, instance_volume_size)
|
160
160
|
Mondupe.new.create_dns(instance_fqdn, route53_domain, instance)
|
161
161
|
Mondupe.new.bootstrap(instance_name, instance_fqdn, instance.ip_address, chef_environment, chef_run_list, ssh_key, ssh_user, knife_exec)
|
162
|
-
Mondupe.new.get_db_dump_from_s3(instance.ip_address, s3_bucket_name, dump_tmp_path, ssh_user, dump_file_name)
|
162
|
+
Mondupe.new.get_db_dump_from_s3(instance.ip_address, s3_bucket_name, dump_tmp_path, ssh_key, ssh_user, dump_file_name)
|
163
163
|
Mondupe.new.restore_db(instance.ip_address, dump_tmp_path, ssh_key, ssh_user, dump_file_name, mongo_db_name, mongo_user, mongo_pass, mongo_auth_db)
|
164
164
|
puts " - - - Total Run Time: #{((total_seconds % 3600) / 60).to_i}m #{((total_seconds % 3600) % 60).to_i}s - - -"
|
165
165
|
when "delete"
|
@@ -170,7 +170,7 @@ when "bootstrap"
|
|
170
170
|
Mondupe.new.bootstrap(instance_name, instance_fqdn, instance_host_address, chef_environment, chef_run_list, ssh_key, ssh_user, knife_exec)
|
171
171
|
when "dumps3"
|
172
172
|
puts "getting dump"
|
173
|
-
Mondupe.new.get_db_dump_from_s3(instance_host_address, s3_bucket_name, dump_tmp_path, ssh_user, dump_file_name)
|
173
|
+
Mondupe.new.get_db_dump_from_s3(instance_host_address, s3_bucket_name, dump_tmp_path, ssh_key, ssh_user, dump_file_name)
|
174
174
|
when "restore"
|
175
175
|
puts "Restoring mongo database from dump"
|
176
176
|
Mondupe.new.restore_db(instance_host_address, dump_tmp_path, ssh_key, ssh_user, dump_file_name, mongo_db_name, mongo_user, mongo_pass, mongo_auth_db)
|
data/lib/mondupe.rb
CHANGED
@@ -69,21 +69,21 @@ class Mondupe
|
|
69
69
|
def create_dns(instance_fqdn, route53_domain, instance)
|
70
70
|
# Set up DNS through Route53
|
71
71
|
puts "Setting up Route53 DNS..."
|
72
|
+
|
72
73
|
# Check to see if record exists
|
73
74
|
route53 = AWS::Route53.new(:access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'])
|
74
75
|
zone = route53.hosted_zones.select { |z| z.name == route53_domain }.first
|
75
|
-
|
76
76
|
rrsets = AWS::Route53::HostedZone.new(zone.id).rrsets
|
77
|
-
rrset = rrsets
|
77
|
+
rrset = rrsets[instance_fqdn, 'CNAME']
|
78
|
+
|
78
79
|
if rrset.exists?
|
79
80
|
# Update if record exists
|
81
|
+
rrset.resource_records = [ { :value => instance.ip_address } ]
|
80
82
|
rrset.update
|
81
83
|
puts "Updated CNAME '#{instance_fqdn}' to point to '#{instance.ip_address}'"
|
82
84
|
else
|
83
85
|
# Create new record if does not exist
|
84
|
-
rrset =
|
85
|
-
rrset.resource_records = [ { :value => instance.ip_address } ]
|
86
|
-
rrset.update
|
86
|
+
rrset = rrsets.create(instance_fqdn, 'CNAME', :ttl => 300, :resource_records => [{:value => instance.ip_address }])
|
87
87
|
puts "Added CNAME '#{instance_fqdn}' pointing to '#{instance.ip_address}'"
|
88
88
|
end
|
89
89
|
end
|
@@ -111,7 +111,7 @@ class Mondupe
|
|
111
111
|
system("#{knife_exec} bootstrap #{instance_ipaddress} -N #{instance_fqdn[0...-1]} -E #{chef_environment} -i #{ssh_key} -r #{chef_run_list} -x #{ssh_user} --sudo") or abort "Knife bootstrap failed"
|
112
112
|
end
|
113
113
|
|
114
|
-
def get_db_dump_from_s3(instance_ip, s3_bucket_name, dump_tmp_path, ssh_user, dump_file_name)
|
114
|
+
def get_db_dump_from_s3(instance_ip, s3_bucket_name, dump_tmp_path, ssh_key, ssh_user, dump_file_name)
|
115
115
|
expiration = Time.now.to_i + 400*60
|
116
116
|
s3 = AWS::S3.new(:access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'])
|
117
117
|
backups = s3.buckets[s3_bucket_name]
|
@@ -120,7 +120,7 @@ class Mondupe
|
|
120
120
|
puts "Download URL: #{download_url}"
|
121
121
|
puts "#{Time.now.to_s} - Starting download."
|
122
122
|
puts " Please wait..."
|
123
|
-
`ssh -i
|
123
|
+
`ssh -i #{ssh_key} #{ssh_user}@#{instance_ip} "sudo mkdir -p #{dump_tmp_path} && sudo chown #{ssh_user}:#{ssh_user} #{dump_tmp_path} && cd #{dump_tmp_path} && wget '#{download_url}' -O #{File.join(dump_tmp_path, dump_file_name)} 2&>1"`
|
124
124
|
puts "#{Time.now.to_s} - Download completed"
|
125
125
|
end
|
126
126
|
|