capones_recipes 0.5.3 → 0.6.0
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.
- data/VERSION +1 -1
- data/capones_recipes.gemspec +1 -1
- data/lib/recipes/database/sync.rb +31 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/capones_recipes.gemspec
CHANGED
@@ -69,6 +69,37 @@ Capistrano::Configuration.instance.load do
|
|
69
69
|
logger.important "sync database from the stage '#{stage}' to local finished"
|
70
70
|
end
|
71
71
|
|
72
|
+
desc <<-DESC
|
73
|
+
Syncs database from the selected mutli_stage environement to the local develoment environment.
|
74
|
+
The database credentials will be read from your local config/database.yml file and a copy of the
|
75
|
+
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
76
|
+
declared in the sync_backups variable and defaults to 5.
|
77
|
+
DESC
|
78
|
+
task :kuhsaft, :roles => :db, :only => { :primary => true } do
|
79
|
+
# Use production on non-multistage
|
80
|
+
set :stage, 'production' unless exists?(:stage)
|
81
|
+
|
82
|
+
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
83
|
+
on_rollback { delete "#{shared_path}/sync/#{filename}" }
|
84
|
+
|
85
|
+
# Remote DB dump
|
86
|
+
username, password, database, host = remote_database_config(stage)
|
87
|
+
host_option = host ? "--host='#{host}'" : ""
|
88
|
+
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|
|
89
|
+
puts data
|
90
|
+
end
|
91
|
+
purge_old_backups "database"
|
92
|
+
|
93
|
+
# Download dump
|
94
|
+
download "#{shared_path}/sync/#{filename}", filename
|
95
|
+
|
96
|
+
# Local DB import
|
97
|
+
username, password, database, host = database_config('development')
|
98
|
+
system "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}; rm -f #{filename}"
|
99
|
+
|
100
|
+
logger.important "sync database from the stage '#{stage}' to local finished"
|
101
|
+
end
|
102
|
+
|
72
103
|
desc <<-DESC
|
73
104
|
Sync declared directories from the selected multi_stage environment to the local development
|
74
105
|
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.6.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Roman Simecek
|
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
163
163
|
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
hash: -
|
165
|
+
hash: -4200710683689644275
|
166
166
|
segments:
|
167
167
|
- 0
|
168
168
|
version: "0"
|