load_remote_db 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/load_remote_db/version.rb +1 -1
- data/lib/tasks/load_remote_db.rake +31 -13
- data/load_remote_db.gemspec +11 -12
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0705b92198785747da391a7e4020bb7c6f764c7f
|
4
|
+
data.tar.gz: 1e0f3f6c569035e3cbf2a826a230f73d587affc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01d65a974dcf8f852cf34c1bd719c5a33eeb5d2f576398a5e38757840d82290c079599625769aeb36fa6cc6377c30d4749c32fc46dacbf218856bf8866a2165d
|
7
|
+
data.tar.gz: '07822d4c51b20080a7bcae1fa23cdc0a66ad22311bfa9076c2ed807241555ee59d9b47f09f08a12e2b1f63ea2ce20ee21d9ef15eb4cb3c7f8b991a60b5f449ee'
|
@@ -24,11 +24,15 @@ class RemoteDbLoader
|
|
24
24
|
password = development_db['password']
|
25
25
|
database = development_db['database']
|
26
26
|
|
27
|
-
|
27
|
+
begin
|
28
|
+
eval File.read("#{Rails.root}/config/deploy.rb")
|
29
|
+
rescue LoadError
|
30
|
+
end
|
28
31
|
eval File.read("#{Rails.root}/config/deploy/#{env}.rb")
|
32
|
+
port = @port || 22
|
29
33
|
|
30
34
|
## get remote database config.yml
|
31
|
-
get_db_info_command = %{ssh #{@server_user}@#{@server_ip} \
|
35
|
+
get_db_info_command = %{ssh #{@server_user}@#{@server_ip} -p#{port} \
|
32
36
|
"/home/#{@server_user}/.rbenv/shims/ruby -e \
|
33
37
|
\\"require 'yaml'; \
|
34
38
|
puts YAML.load_file('#{@deploy_to}/shared/config/database.yml')['#{env}']\\""}
|
@@ -46,12 +50,12 @@ class RemoteDbLoader
|
|
46
50
|
puts 'Running the remote backup...'
|
47
51
|
mysql_cmd = "mysqldump -u #{remote_db_username} -p'#{remote_db_password}' \
|
48
52
|
-h #{remote_db_host} #{remote_db_name} > #{shared_path}/backup.sql".shellescape
|
49
|
-
backup_command = %(ssh #{@server_user}@#{@server_ip} #{mysql_cmd})
|
53
|
+
backup_command = %(ssh #{@server_user}@#{@server_ip} -p#{port} #{mysql_cmd})
|
50
54
|
system(backup_command)
|
51
55
|
|
52
56
|
check_gzip_exist_cmd = 'which gzip'
|
53
57
|
check_gzip_exist_remote_cmd =
|
54
|
-
%(ssh #{@server_user}@#{@server_ip} #{check_gzip_exist_cmd})
|
58
|
+
%(ssh #{@server_user}@#{@server_ip} -p#{port} #{check_gzip_exist_cmd})
|
55
59
|
|
56
60
|
puts 'Checking for remote gzip location...'
|
57
61
|
gzip_exist = system(check_gzip_exist_remote_cmd) != ''
|
@@ -60,19 +64,19 @@ class RemoteDbLoader
|
|
60
64
|
puts 'zipping remote backup file...'
|
61
65
|
zip_cmd = "gzip -f #{shared_path}/backup.sql"
|
62
66
|
zip_cmd_remote =
|
63
|
-
%(ssh #{@server_user}@#{@server_ip} #{zip_cmd})
|
67
|
+
%(ssh #{@server_user}@#{@server_ip} -p#{port} #{zip_cmd})
|
64
68
|
system(zip_cmd_remote)
|
65
69
|
end
|
66
70
|
|
67
71
|
puts 'Downloading remote backup file...'
|
68
72
|
bk_extension = gzip_exist ? 'sql.gz' : 'sql'
|
69
73
|
download_db_dump_command =
|
70
|
-
%(scp #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
|
74
|
+
%(scp -P#{port} #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
|
71
75
|
|
72
76
|
system(download_db_dump_command)
|
73
77
|
|
74
78
|
puts 'Deleting remote backup file...'
|
75
|
-
delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} \
|
79
|
+
delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} -p#{port} \
|
76
80
|
"rm -rf #{shared_path}/backup.#{bk_extension}")
|
77
81
|
|
78
82
|
system(delete_db_dump_command)
|
@@ -117,8 +121,21 @@ class RemoteDbLoader
|
|
117
121
|
end
|
118
122
|
|
119
123
|
def method_missing(name, *args, &block)
|
120
|
-
|
121
|
-
|
124
|
+
if name == :fetch && args[0] == :deploy_user
|
125
|
+
return @server_user
|
126
|
+
end
|
127
|
+
|
128
|
+
if name == :fetch && args[0] == :application
|
129
|
+
return @application
|
130
|
+
end
|
131
|
+
|
132
|
+
if name == :fetch && args[0] == :full_app_name
|
133
|
+
return @full_app_name
|
134
|
+
end
|
135
|
+
|
136
|
+
if name == :fetch && args[0] == :stage
|
137
|
+
return @stage
|
138
|
+
end
|
122
139
|
|
123
140
|
return self unless %I[server set].include?(name)
|
124
141
|
@server_ip ||= if name == :server
|
@@ -127,10 +144,11 @@ class RemoteDbLoader
|
|
127
144
|
args[1]
|
128
145
|
end
|
129
146
|
@server_user ||= args[1] if name == :set && args[0] == :user
|
147
|
+
@stage ||= args[1] if name == :set && args[0] == :stage
|
148
|
+
@server_user = args[1] if name == :set && args[0] == :deploy_user
|
130
149
|
@application ||= args[1] if name == :set && args[0] == :application
|
131
|
-
@
|
132
|
-
if name == :set && args[0] == :
|
133
|
-
|
134
|
-
end
|
150
|
+
@full_app_name ||= args[1] if name == :set && args[0] == :full_app_name
|
151
|
+
@port ||= args[1] if name == :set && args[0] == :port
|
152
|
+
@deploy_to ||= args[1] if name == :set && args[0] == :deploy_to
|
135
153
|
end
|
136
154
|
end
|
data/load_remote_db.gemspec
CHANGED
@@ -1,26 +1,25 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'load_remote_db/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'load_remote_db'
|
8
7
|
spec.version = LoadRemoteDb::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['James Huynh']
|
9
|
+
spec.email = ['james@rubify.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'Load MySQL Remote DB for Mina/Capistrano'
|
12
|
+
spec.description = 'Load MySQL Remote DB for Mina/Capistrano'
|
13
|
+
spec.homepage = 'https://github.com/jameshuynh/load_remote_db'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
17
|
f.match(%r{^(test|spec|features)/})
|
19
18
|
end
|
20
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
21
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
23
22
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: load_remote_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Huynh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,4 +82,3 @@ signing_key:
|
|
82
82
|
specification_version: 4
|
83
83
|
summary: Load MySQL Remote DB for Mina/Capistrano
|
84
84
|
test_files: []
|
85
|
-
has_rdoc:
|