cloner 0.5.1 → 0.5.2
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/lib/cloner/mongodb.rb +12 -3
- data/lib/cloner/postgres.rb +11 -4
- data/lib/cloner/rsync.rb +2 -1
- data/lib/cloner/ssh.rb +7 -0
- data/lib/cloner/version.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d8735e858cfef73a306c3c97b2e28025f796b7
|
4
|
+
data.tar.gz: 0fefb2d9aaf996acdaa975efd96e65dbf5ccbfc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94388283f46759e3b2ba846c0cc2e0713b6f4c65c1b210be9b061e8be678ee1ebc2956830aab9b535d979086135a8c93dbb696cf903c349dbdae60081aa81935
|
7
|
+
data.tar.gz: 50ac11a234d90e286506e68e89b03f390f4ab4818c8be8454bd7385217c7fb9e4cc3327fec573b65a9fda80427e1c3e739b6ae8cef9290dafcfa26eb0fbbd71e
|
data/lib/cloner/mongodb.rb
CHANGED
@@ -18,10 +18,19 @@ module Cloner::MongoDB
|
|
18
18
|
|
19
19
|
def mongodb_r_conf
|
20
20
|
@r_conf ||= begin
|
21
|
-
|
21
|
+
do_ssh do |ssh|
|
22
22
|
ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/mongoid.yml')}")
|
23
23
|
check_ssh_err(ret)
|
24
|
-
|
24
|
+
|
25
|
+
begin
|
26
|
+
yml = YAML.load(ret[0])[env_from]
|
27
|
+
raise 'no data' if yml.blank?
|
28
|
+
rescue Exception => e
|
29
|
+
puts "unable to read remote database.yml for env #{env_from}."
|
30
|
+
puts "Remote file contents:"
|
31
|
+
puts ret[0]
|
32
|
+
end
|
33
|
+
|
25
34
|
if yml.key?('sessions')
|
26
35
|
yml['sessions']['default']
|
27
36
|
else
|
@@ -43,7 +52,7 @@ module Cloner::MongoDB
|
|
43
52
|
|
44
53
|
def mongodb_dump_remote
|
45
54
|
puts "backup remote DB via ssh"
|
46
|
-
|
55
|
+
do_ssh do |ssh|
|
47
56
|
ssh.exec!("rm -R #{remote_dump_path}")
|
48
57
|
ret = ssh_exec!(ssh, "mkdir -p #{remote_dump_path}")
|
49
58
|
check_ssh_err(ret)
|
data/lib/cloner/postgres.rb
CHANGED
@@ -13,11 +13,18 @@ module Cloner::Postgres
|
|
13
13
|
|
14
14
|
def ar_r_conf
|
15
15
|
@ar_r_conf ||= begin
|
16
|
-
|
16
|
+
do_ssh do |ssh|
|
17
17
|
ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/database.yml')}")
|
18
18
|
check_ssh_err(ret)
|
19
|
-
|
20
|
-
|
19
|
+
begin
|
20
|
+
res = YAML.load(ret[0])[env_from]
|
21
|
+
raise 'no data' if res.blank?
|
22
|
+
res['host'] ||= '127.0.0.1'
|
23
|
+
rescue Exception => e
|
24
|
+
puts "unable to read remote database.yml for env #{env_from}."
|
25
|
+
puts "Remote file contents:"
|
26
|
+
puts ret[0]
|
27
|
+
end
|
21
28
|
res
|
22
29
|
end
|
23
30
|
end
|
@@ -41,7 +48,7 @@ module Cloner::Postgres
|
|
41
48
|
|
42
49
|
def pg_dump_remote
|
43
50
|
puts "backup remote DB via ssh"
|
44
|
-
|
51
|
+
do_ssh do |ssh|
|
45
52
|
ssh.exec!("rm -R #{e remote_dump_path}")
|
46
53
|
ret = ssh_exec!(ssh, "mkdir -p #{e remote_dump_path}")
|
47
54
|
check_ssh_err(ret)
|
data/lib/cloner/rsync.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Cloner::RSync
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
def rsync(from, to)
|
4
|
-
|
4
|
+
port = ssh_opts[:port] || 22
|
5
|
+
cmd = "rsync -e ssh -zutvr --checksum -e \"ssh -p #{port}\" #{e ssh_user}@#{e ssh_host}:#{e from}/ #{e to}/"
|
5
6
|
puts "Running RSync: #{cmd}"
|
6
7
|
pipe = IO.popen(cmd)
|
7
8
|
while (line = pipe.gets)
|
data/lib/cloner/ssh.rb
CHANGED
@@ -5,6 +5,12 @@ module Cloner::SSH
|
|
5
5
|
{}
|
6
6
|
end
|
7
7
|
|
8
|
+
def do_ssh(&block)
|
9
|
+
Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
|
10
|
+
yield ssh
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
# http://stackoverflow.com/questions/3386233/how-to-get-exit-status-with-rubys-netssh-library
|
9
15
|
def ssh_exec!(ssh, command)
|
10
16
|
stdout_data = ""
|
@@ -46,3 +52,4 @@ module Cloner::SSH
|
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
55
|
+
|
data/lib/cloner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.4.5
|
126
|
+
rubygems_version: 2.4.5.1
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Easily clone your production Mongoid database and files for local development
|