capones_recipes 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/capones_recipes.gemspec +1 -3
- data/lib/recipes/database/sync.rb +41 -0
- metadata +2 -4
- data/lib/recipes/kuhsaft/sync.rb +0 -15
- data/lib/recipes/kuhsaft.rb +0 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/capones_recipes.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{capones_recipes}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Roman Simecek"]
|
@@ -40,8 +40,6 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/recipes/katalog.rb",
|
41
41
|
"lib/recipes/katalog/import.rb",
|
42
42
|
"lib/recipes/katalog/katalog.rb",
|
43
|
-
"lib/recipes/kuhsaft.rb",
|
44
|
-
"lib/recipes/kuhsaft/sync.rb",
|
45
43
|
"lib/recipes/new_relic.rb",
|
46
44
|
"lib/recipes/new_relic/new_relic.rb",
|
47
45
|
"lib/recipes/rails.rb",
|
@@ -178,6 +178,47 @@ Capistrano::Configuration.instance.load do
|
|
178
178
|
logger.important "sync database from local to the stage '#{stage}' finished"
|
179
179
|
end
|
180
180
|
|
181
|
+
desc <<-DESC
|
182
|
+
Syncs database from the local develoment environment to the selected mutli_stage environement.
|
183
|
+
The database credentials will be read from your local config/database.yml file and a copy of the
|
184
|
+
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
185
|
+
declared in the sync_backups variable and defaults to 5.
|
186
|
+
DESC
|
187
|
+
task :kuhsaft, :roles => :db, :only => { :primary => true } do
|
188
|
+
# Use production on non-multistage
|
189
|
+
set :stage, 'production' unless exists?(:stage)
|
190
|
+
|
191
|
+
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
192
|
+
|
193
|
+
on_rollback do
|
194
|
+
delete "#{shared_path}/sync/#{filename}"
|
195
|
+
system "rm -f #{filename}"
|
196
|
+
end
|
197
|
+
|
198
|
+
# Make a backup before importing
|
199
|
+
username, password, database, host = remote_database_config(stage)
|
200
|
+
host_option = host ? "--host='#{host}'" : ""
|
201
|
+
run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} pages localized_pages contents assets tags taggings | bzip2 -9 > #{shared_path}/sync/#{filename}" do |channel, stream, data|
|
202
|
+
puts data
|
203
|
+
end
|
204
|
+
|
205
|
+
# Local DB export
|
206
|
+
filename = "dump.local.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
207
|
+
username, password, database, host = database_config('development')
|
208
|
+
host_option = host ? "--host='#{host}'" : ""
|
209
|
+
system "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}"
|
210
|
+
upload filename, "#{shared_path}/sync/#{filename}"
|
211
|
+
system "rm -f #{filename}"
|
212
|
+
|
213
|
+
# Remote DB import
|
214
|
+
username, password, database, host = remote_database_config(stage)
|
215
|
+
host_option = host ? "--host='#{host}'" : ""
|
216
|
+
run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}; rm -f #{shared_path}/sync/#{filename}"
|
217
|
+
purge_old_backups "database"
|
218
|
+
|
219
|
+
logger.important "sync database from local to the stage '#{stage}' finished"
|
220
|
+
end
|
221
|
+
|
181
222
|
desc <<-DESC
|
182
223
|
Sync declared directories from the local development environement to the selected multi_stage
|
183
224
|
environment. The synced directories must be declared as an array of Strings with the sync_directories
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: capones_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.7.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Roman Simecek
|
@@ -134,8 +134,6 @@ files:
|
|
134
134
|
- lib/recipes/katalog.rb
|
135
135
|
- lib/recipes/katalog/import.rb
|
136
136
|
- lib/recipes/katalog/katalog.rb
|
137
|
-
- lib/recipes/kuhsaft.rb
|
138
|
-
- lib/recipes/kuhsaft/sync.rb
|
139
137
|
- lib/recipes/new_relic.rb
|
140
138
|
- lib/recipes/new_relic/new_relic.rb
|
141
139
|
- lib/recipes/rails.rb
|
@@ -162,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
160
|
requirements:
|
163
161
|
- - ">="
|
164
162
|
- !ruby/object:Gem::Version
|
165
|
-
hash: -
|
163
|
+
hash: -125520120456256867
|
166
164
|
segments:
|
167
165
|
- 0
|
168
166
|
version: "0"
|
data/lib/recipes/kuhsaft/sync.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance.load do
|
2
|
-
namespace :kuhsaft do
|
3
|
-
namespace :sync do
|
4
|
-
desc "Syncs down the tables of kuhsaft"
|
5
|
-
task :down do
|
6
|
-
puts 'TODO: kuhsaft down'
|
7
|
-
end
|
8
|
-
|
9
|
-
desc "Syncs up the tables of kuhsaft"
|
10
|
-
task :up do
|
11
|
-
puts 'TODO: kuhsaft up'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/recipes/kuhsaft.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Dir.glob(File.join(File.dirname(__FILE__), '/kuhsaft/*.rb')).sort.each { |f| load f }
|