recipiez 0.6.11 → 0.6.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/recipiez/version.rb +1 -1
- data/recipes/deployment_recipiez.rb +37 -2
- metadata +3 -3
data/lib/recipiez/version.rb
CHANGED
@@ -116,6 +116,34 @@ namespace :recipiez do
|
|
116
116
|
puts "All done!"
|
117
117
|
end
|
118
118
|
|
119
|
+
desc "Dump alternate database, copy it across and restore it locally"
|
120
|
+
task :pull_alternate do
|
121
|
+
set_variables_from_yaml(alternate_yaml_env)
|
122
|
+
archive = generate_archive(application)
|
123
|
+
filename = get_filename(application)
|
124
|
+
cmd = "mysqldump --opt --skip-add-locks -u #{db_user} "
|
125
|
+
cmd += " -h #{db_host} " if exists?('db_host')
|
126
|
+
cmd += " -p#{db_password} "
|
127
|
+
cmd += "#{database_to_dump} > #{archive}"
|
128
|
+
result = run(cmd)
|
129
|
+
|
130
|
+
cmd = "rsync -av -e \"ssh -p #{ssh_options[:port]} #{get_identities}\" #{user}@#{roles[:db].servers.first}:#{archive} #{dump_dir}#{filename}"
|
131
|
+
puts "running #{cmd}"
|
132
|
+
result = system(cmd)
|
133
|
+
puts result
|
134
|
+
run "rm #{archive}"
|
135
|
+
|
136
|
+
puts "Restoring db"
|
137
|
+
begin
|
138
|
+
`mysqladmin -u#{db_local_user} -p#{db_local_password} --force drop #{db_dev}`
|
139
|
+
rescue
|
140
|
+
# do nothing
|
141
|
+
end
|
142
|
+
`mysqladmin -u#{db_local_user} -p#{db_local_password} --force create #{db_dev}`
|
143
|
+
`cat #{dump_dir}#{get_filename(application)} | mysql -u#{db_local_user} -p#{db_local_password} #{db_dev}`
|
144
|
+
puts "All done!"
|
145
|
+
end
|
146
|
+
|
119
147
|
desc "Push up the db"
|
120
148
|
task :push do
|
121
149
|
set_variables_from_yaml
|
@@ -310,14 +338,21 @@ def format_svn_log(current_revision, previous_revision)
|
|
310
338
|
end
|
311
339
|
|
312
340
|
|
313
|
-
|
341
|
+
# Need to consider how to have an alternative yaml environment.
|
342
|
+
def set_variables_from_yaml(alternate_environment = "")
|
343
|
+
|
344
|
+
if alternate_environment
|
345
|
+
yaml_env = alternate_environment
|
346
|
+
else
|
347
|
+
yaml_env = rails_env
|
348
|
+
end
|
314
349
|
|
315
350
|
unless File.exists?("config/recipiez.yml")
|
316
351
|
raise StandardError, "You need a config/recipiez.yml file which defines the database syncing settings. Run recipiez:generate_config"
|
317
352
|
end
|
318
353
|
|
319
354
|
global = YAML.load_file("config/recipiez.yml")
|
320
|
-
app_config = global[
|
355
|
+
app_config = global[yaml_env]
|
321
356
|
app_config.each_pair do |key, value|
|
322
357
|
set key.to_sym, value
|
323
358
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 12
|
9
|
+
version: 0.6.12
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alastair Brunton
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2014-
|
17
|
+
date: 2014-07-15 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|