cloner 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloner/internal.rb +4 -0
- data/lib/cloner/mongodb.rb +4 -4
- data/lib/cloner/postgres.rb +10 -9
- data/lib/cloner/rsync.rb +1 -1
- data/lib/cloner/version.rb +1 -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: cea32c10a5456a2af0d37b26384e651e1234f16d
|
4
|
+
data.tar.gz: ffcd5ad320f56b8ea5e627f751e677af51647edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84ce1cfcd5e9875cbb06aee952fab09413fd99bbe128d86d5c0e9264f5a5af1784be4b3e49737e72c6a4acc2f421e33fcfb6e82b42aba59fb06c2c3f672eecc1
|
7
|
+
data.tar.gz: 1eb36edc996a3f00a1985af522f474644dc092a389d33f624b85d3212338210f4047ebaa221f3dcf92b5fb065756db547b087be320661ca81d9dd4674f756209
|
data/lib/cloner/internal.rb
CHANGED
data/lib/cloner/mongodb.rb
CHANGED
@@ -14,7 +14,7 @@ module Cloner::MongoDB
|
|
14
14
|
def mongodb_r_conf
|
15
15
|
@r_conf ||= begin
|
16
16
|
Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
|
17
|
-
ret = ssh_exec!(ssh, "cat #{remote_app_path
|
17
|
+
ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/mongoid.yml')}")
|
18
18
|
check_ssh_err(ret)
|
19
19
|
YAML.load(ret[0])[env_from]['sessions']['default']
|
20
20
|
end
|
@@ -25,7 +25,7 @@ module Cloner::MongoDB
|
|
25
25
|
if mongodb_conf['password'].nil?
|
26
26
|
""
|
27
27
|
else
|
28
|
-
"-u #{mongodb_conf['username']} -p #{mongodb_conf['password']}"
|
28
|
+
"-u #{e mongodb_conf['username']} -p #{e mongodb_conf['password']}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -35,7 +35,7 @@ module Cloner::MongoDB
|
|
35
35
|
ssh.exec!("rm -R #{remote_dump_path}")
|
36
36
|
ret = ssh_exec!(ssh, "mkdir -p #{remote_dump_path}")
|
37
37
|
check_ssh_err(ret)
|
38
|
-
dump = "mongodump -u #{mongodb_r_conf['username']} -p #{mongodb_r_conf['password']} -d #{mongodb_r_conf['database']} --authenticationDatabase #{mongodb_r_conf['database']} -o #{remote_dump_path}"
|
38
|
+
dump = "mongodump -u #{e mongodb_r_conf['username']} -p #{e mongodb_r_conf['password']} -d #{e mongodb_r_conf['database']} --authenticationDatabase #{e mongodb_r_conf['database']} -o #{e remote_dump_path}"
|
39
39
|
puts dump if verbose?
|
40
40
|
ret = ssh_exec!(ssh, dump)
|
41
41
|
check_ssh_err(ret)
|
@@ -44,7 +44,7 @@ module Cloner::MongoDB
|
|
44
44
|
|
45
45
|
def mongodb_dump_restore
|
46
46
|
puts "restoring DB"
|
47
|
-
restore = "mongorestore --drop -d #{mongodb_to} #{mongodb_local_auth} #{mongodb_path}"
|
47
|
+
restore = "mongorestore --drop -d #{e mongodb_to} #{mongodb_local_auth} #{e mongodb_path}"
|
48
48
|
puts restore if verbose?
|
49
49
|
pipe = IO.popen(restore)
|
50
50
|
while (line = pipe.gets)
|
data/lib/cloner/postgres.rb
CHANGED
@@ -8,16 +8,17 @@ module Cloner::Postgres
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def ar_to
|
11
|
-
p ar_conf
|
12
11
|
ar_conf['database']
|
13
12
|
end
|
14
13
|
|
15
14
|
def ar_r_conf
|
16
15
|
@ar_r_conf ||= begin
|
17
16
|
Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
|
18
|
-
ret = ssh_exec!(ssh, "cat #{remote_app_path
|
17
|
+
ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/database.yml')}")
|
19
18
|
check_ssh_err(ret)
|
20
|
-
YAML.load(ret[0])[env_from]
|
19
|
+
res = YAML.load(ret[0])[env_from]
|
20
|
+
res['host'] ||= '127.0.0.1'
|
21
|
+
res
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -41,10 +42,10 @@ module Cloner::Postgres
|
|
41
42
|
def pg_dump_remote
|
42
43
|
puts "backup remote DB via ssh"
|
43
44
|
Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
|
44
|
-
ssh.exec!("rm -R #{remote_dump_path}")
|
45
|
-
ret = ssh_exec!(ssh, "mkdir -p #{remote_dump_path}")
|
45
|
+
ssh.exec!("rm -R #{e remote_dump_path}")
|
46
|
+
ret = ssh_exec!(ssh, "mkdir -p #{e remote_dump_path}")
|
46
47
|
check_ssh_err(ret)
|
47
|
-
dump = pg_remote_auth + "pg_dump -Fc -U #{ar_r_conf['username']} #{ar_r_conf['database']} > #{remote_dump_path
|
48
|
+
dump = pg_remote_auth + "pg_dump -Fc -U #{e ar_r_conf['username']} -h #{e ar_r_conf['host']} #{e ar_r_conf['database']} > #{e(remote_dump_path + '/tmp.bak')}"
|
48
49
|
puts dump if verbose?
|
49
50
|
ret = ssh_exec!(ssh, dump)
|
50
51
|
check_ssh_err(ret)
|
@@ -53,7 +54,7 @@ module Cloner::Postgres
|
|
53
54
|
|
54
55
|
def pg_dump_restore
|
55
56
|
puts "restoring DB"
|
56
|
-
restore = pg_local_auth + "pg_restore -Fc -c -U #{ar_conf['username']} -d #{ar_to} #{pg_path
|
57
|
+
restore = pg_local_auth + "pg_restore -Fc -c -U #{e ar_conf['username']} -d #{e ar_to} #{e(pg_path + '/tmp.bak')}"
|
57
58
|
puts restore
|
58
59
|
puts restore if verbose?
|
59
60
|
pipe = IO.popen(restore)
|
@@ -72,8 +73,8 @@ module Cloner::Postgres
|
|
72
73
|
|
73
74
|
def pg_dump_copy
|
74
75
|
FileUtils.mkdir_p(pg_path)
|
75
|
-
`mkdir -p #{pg_path}`
|
76
|
-
rsync(
|
76
|
+
`mkdir -p #{e pg_path}`
|
77
|
+
rsync(remote_dump_path + '/', pg_path)
|
77
78
|
end
|
78
79
|
|
79
80
|
def clone_pg
|
data/lib/cloner/rsync.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cloner::RSync
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
def rsync(from, to)
|
4
|
-
cmd = "rsync -e ssh -zutvr --checksum #{ssh_user}@#{ssh_host}:#{from}/ #{to}/"
|
4
|
+
cmd = "rsync -e ssh -zutvr --checksum #{e ssh_user}@#{e ssh_host}:#{e from}/ #{e to}/"
|
5
5
|
puts "Running RSync: #{cmd}"
|
6
6
|
pipe = IO.popen(cmd)
|
7
7
|
while (line = pipe.gets)
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-01 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.
|
126
|
+
rubygems_version: 2.4.5
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Easily clone your production Mongoid database and files for local development
|