capones_recipes 1.10.0 → 1.11.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/lib/capones_recipes/tasks/database/sync.rb +0 -195
- data/lib/capones_recipes/tasks/kuhsaft.rb +1 -16
- data/lib/capones_recipes/tasks/kuhsaft/kuhsaft.rb +16 -0
- data/lib/capones_recipes/tasks/kuhsaft/sync.rb +92 -0
- data/lib/capones_recipes/tasks/sync.rb +1 -0
- data/lib/capones_recipes/tasks/sync/fs.rb +63 -0
- data/lib/capones_recipes/tasks/sync/sync.rb +61 -0
- data/lib/capones_recipes/version.rb +1 -1
- metadata +9 -4
@@ -15,29 +15,8 @@ Capistrano::Configuration.instance.load do
|
|
15
15
|
# Kindly sponsored by Screen Concept, www.screenconcept.ch
|
16
16
|
#
|
17
17
|
namespace :sync do
|
18
|
-
|
19
|
-
after "deploy:setup", "sync:setup"
|
20
|
-
|
21
|
-
desc <<-DESC
|
22
|
-
Creates the sync dir in shared path. The sync directory is used to keep
|
23
|
-
backups of database dumps and archives from synced directories. This task will
|
24
|
-
be called on 'deploy:setup'
|
25
|
-
DESC
|
26
|
-
task :setup do
|
27
|
-
run "mkdir -p #{shared_path}/sync"
|
28
|
-
end
|
29
|
-
|
30
18
|
namespace :down do
|
31
19
|
|
32
|
-
desc <<-DESC
|
33
|
-
Syncs the database and declared directories from the selected multi_stage environment
|
34
|
-
to the local development environment. This task simply calls both the 'sync:down:db' and
|
35
|
-
'sync:down:fs' tasks.
|
36
|
-
DESC
|
37
|
-
task :default do
|
38
|
-
db and fs
|
39
|
-
end
|
40
|
-
|
41
20
|
desc <<-DESC
|
42
21
|
Syncs database from the selected mutli_stage environement to the local develoment environment.
|
43
22
|
The database credentials will be read from your local config/database.yml file and a copy of the
|
@@ -74,87 +53,10 @@ Capistrano::Configuration.instance.load do
|
|
74
53
|
run_locally "rake db:migrate"
|
75
54
|
end
|
76
55
|
|
77
|
-
desc <<-DESC
|
78
|
-
Sync declared directories from the selected multi_stage environment to the local development
|
79
|
-
environment. The synced directories must be declared as an array of Strings with the sync_directories
|
80
|
-
variable. The path is relative to the rails root.
|
81
|
-
DESC
|
82
|
-
task :fs, :roles => :web, :once => true do
|
83
|
-
# Use production on non-multistage
|
84
|
-
set :stage, 'production' unless exists?(:stage)
|
85
|
-
|
86
|
-
server, port = host_and_port
|
87
|
-
|
88
|
-
Array(fetch(:sync_directories, [])).each do |syncdir|
|
89
|
-
unless File.directory? "#{syncdir}"
|
90
|
-
logger.info "create local '#{syncdir}' folder"
|
91
|
-
Dir.mkdir "#{syncdir}"
|
92
|
-
end
|
93
|
-
logger.info "sync #{syncdir} from #{server}:#{port} to local"
|
94
|
-
destination, base = Pathname.new(syncdir).split
|
95
|
-
run_locally "rsync --verbose --archive --compress --copy-links --delete --stats --rsh='ssh -p #{port}' #{user}@#{server}:#{current_path}/#{syncdir} #{destination.to_s}"
|
96
|
-
end
|
97
|
-
|
98
|
-
logger.important "sync filesystem from the stage '#{stage}' to local finished"
|
99
|
-
end
|
100
|
-
|
101
|
-
namespace :kuhsaft do
|
102
|
-
|
103
|
-
desc <<-DESC
|
104
|
-
Syncs the database and declared directories from the selected multi_stage environment
|
105
|
-
to the local development environment. This task simply calls both the 'sync:down:kuhsaft:db' and
|
106
|
-
'sync:down:kuhsaft:fs' tasks.
|
107
|
-
DESC
|
108
|
-
task :default do
|
109
|
-
db
|
110
|
-
end
|
111
|
-
|
112
|
-
desc <<-DESC
|
113
|
-
Syncs database from the selected mutli_stage environement to the local develoment environment.
|
114
|
-
The database credentials will be read from your local config/database.yml file and a copy of the
|
115
|
-
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
116
|
-
declared in the sync_backups variable and defaults to 5.
|
117
|
-
DESC
|
118
|
-
task :db, :roles => :db, :only => { :primary => true } do
|
119
|
-
# Use production on non-multistage
|
120
|
-
set :stage, 'production' unless exists?(:stage)
|
121
|
-
|
122
|
-
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
123
|
-
on_rollback { delete "#{shared_path}/sync/#{filename}" }
|
124
|
-
|
125
|
-
# Remote DB dump
|
126
|
-
username, password, database, host = remote_database_config(stage)
|
127
|
-
host_option = host ? "--host='#{host}'" : ""
|
128
|
-
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|
|
129
|
-
puts data
|
130
|
-
end
|
131
|
-
purge_old_backups "database"
|
132
|
-
|
133
|
-
# Download dump
|
134
|
-
download "#{shared_path}/sync/#{filename}", filename
|
135
|
-
|
136
|
-
# Local DB import
|
137
|
-
username, password, database, host = database_config('development')
|
138
|
-
run_locally "rake db:drop && rake db:create"
|
139
|
-
run_locally "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}"
|
140
|
-
run_locally "rm -f #{filename}"
|
141
|
-
|
142
|
-
logger.important "sync database from the stage '#{stage}' to local finished"
|
143
|
-
end
|
144
|
-
end
|
145
56
|
end
|
146
57
|
|
147
58
|
namespace :up do
|
148
59
|
|
149
|
-
desc <<-DESC
|
150
|
-
Syncs the database and declared directories from the local development environment
|
151
|
-
to the selected multi_stage environment. This task simply calls both the 'sync:up:db' and
|
152
|
-
'sync:up:fs' tasks.
|
153
|
-
DESC
|
154
|
-
task :default do
|
155
|
-
db and fs
|
156
|
-
end
|
157
|
-
|
158
60
|
desc <<-DESC
|
159
61
|
Syncs database from the local develoment environment to the selected mutli_stage environement.
|
160
62
|
The database credentials will be read from your local config/database.yml file and a copy of the
|
@@ -197,88 +99,6 @@ Capistrano::Configuration.instance.load do
|
|
197
99
|
logger.important "sync database from local to the stage '#{stage}' finished"
|
198
100
|
end
|
199
101
|
|
200
|
-
desc <<-DESC
|
201
|
-
Sync declared directories from the local development environement to the selected multi_stage
|
202
|
-
environment. The synced directories must be declared as an array of Strings with the sync_directories
|
203
|
-
variable. The path is relative to the rails root.
|
204
|
-
DESC
|
205
|
-
task :fs, :roles => :web, :once => true do
|
206
|
-
# Use production on non-multistage
|
207
|
-
set :stage, 'production' unless exists?(:stage)
|
208
|
-
|
209
|
-
server, port = host_and_port
|
210
|
-
Array(fetch(:sync_directories, [])).each do |syncdir|
|
211
|
-
destination, base = Pathname.new(syncdir).split
|
212
|
-
if File.directory? "#{syncdir}"
|
213
|
-
# Make a backup
|
214
|
-
logger.info "backup #{syncdir}"
|
215
|
-
run "tar cjf #{shared_path}/sync/#{base}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.tar.bz2 #{current_path}/#{syncdir}"
|
216
|
-
purge_old_backups "#{base}"
|
217
|
-
else
|
218
|
-
logger.info "Create '#{syncdir}' directory"
|
219
|
-
run "mkdir #{current_path}/#{syncdir}"
|
220
|
-
end
|
221
|
-
|
222
|
-
# Sync directory up
|
223
|
-
logger.info "sync #{syncdir} to #{server}:#{port} from local"
|
224
|
-
run_locally "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir} #{user}@#{server}:#{current_path}/#{destination.to_s}"
|
225
|
-
end
|
226
|
-
logger.important "sync filesystem from local to the stage '#{stage}' finished"
|
227
|
-
end
|
228
|
-
|
229
|
-
namespace :kuhsaft do
|
230
|
-
|
231
|
-
desc <<-DESC
|
232
|
-
Syncs the database and declared directories from the local development environment
|
233
|
-
to the selected multi_stage environment. This task simply calls both the 'sync:up:kuhsaft:db' task.
|
234
|
-
DESC
|
235
|
-
task :default do
|
236
|
-
db
|
237
|
-
end
|
238
|
-
|
239
|
-
desc <<-DESC
|
240
|
-
Syncs database from the local develoment environment to the selected mutli_stage environement.
|
241
|
-
The database credentials will be read from your local config/database.yml file and a copy of the
|
242
|
-
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
243
|
-
declared in the sync_backups variable and defaults to 5.
|
244
|
-
DESC
|
245
|
-
task :db, :roles => :db, :only => { :primary => true } do
|
246
|
-
# Use production on non-multistage
|
247
|
-
set :stage, 'production' unless exists?(:stage)
|
248
|
-
|
249
|
-
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
250
|
-
|
251
|
-
on_rollback do
|
252
|
-
delete "#{shared_path}/sync/#{filename}"
|
253
|
-
run_locally "rm -f #{filename}"
|
254
|
-
end
|
255
|
-
|
256
|
-
# Make a backup before importing
|
257
|
-
username, password, database, host = remote_database_config(stage)
|
258
|
-
host_option = host ? "--host='#{host}'" : ""
|
259
|
-
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|
|
260
|
-
puts data
|
261
|
-
end
|
262
|
-
|
263
|
-
# Local DB export
|
264
|
-
filename = "dump.local.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
265
|
-
username, password, database, host = database_config('development')
|
266
|
-
host_option = host ? "--host='#{host}'" : ""
|
267
|
-
run_locally "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}"
|
268
|
-
upload filename, "#{shared_path}/sync/#{filename}"
|
269
|
-
run_locally "rm -f #{filename}"
|
270
|
-
|
271
|
-
# Remote DB import
|
272
|
-
username, password, database, host = remote_database_config(stage)
|
273
|
-
host_option = host ? "--host='#{host}'" : ""
|
274
|
-
run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}"
|
275
|
-
run "rm -f #{shared_path}/sync/#{filename}"
|
276
|
-
purge_old_backups "database.kuhsaft"
|
277
|
-
|
278
|
-
logger.important "sync database from local to the stage '#{stage}' finished"
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
102
|
end
|
283
103
|
|
284
104
|
#
|
@@ -310,20 +130,5 @@ Capistrano::Configuration.instance.load do
|
|
310
130
|
return roles[:web].servers.first.host, ssh_options[:port] || roles[:web].servers.first.port || 22
|
311
131
|
end
|
312
132
|
|
313
|
-
#
|
314
|
-
# Purge old backups within the shared sync directory
|
315
|
-
#
|
316
|
-
def purge_old_backups(base)
|
317
|
-
count = fetch(:sync_backups, 5).to_i
|
318
|
-
backup_files = capture("ls -xt #{shared_path}/sync/#{base}*").split.reverse
|
319
|
-
if count >= backup_files.length
|
320
|
-
logger.important "no old backups to clean up"
|
321
|
-
else
|
322
|
-
logger.info "keeping #{count} of #{backup_files.length} sync backups"
|
323
|
-
delete_backups = (backup_files - backup_files.last(count)).join(" ")
|
324
|
-
try_sudo "rm -rf #{delete_backups}"
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
133
|
end
|
329
134
|
end
|
@@ -1,16 +1 @@
|
|
1
|
-
|
2
|
-
before "deploy:setup", "kuhsaft:setup"
|
3
|
-
after "deploy:update_code", "kuhsaft:symlink"
|
4
|
-
|
5
|
-
namespace :kuhsaft do
|
6
|
-
desc "Create uploads directory in capistrano shared path"
|
7
|
-
task :setup do
|
8
|
-
run "mkdir -p #{shared_path}/uploads"
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "Make symlink for shared uploads"
|
12
|
-
task :symlink do
|
13
|
-
run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), '/kuhsaft/*.rb')).sort.each { |f| require f }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
before "deploy:setup", "kuhsaft:setup"
|
3
|
+
after "deploy:update_code", "kuhsaft:symlink"
|
4
|
+
|
5
|
+
namespace :kuhsaft do
|
6
|
+
desc "Create uploads directory in capistrano shared path"
|
7
|
+
task :setup do
|
8
|
+
run "mkdir -p #{shared_path}/uploads"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Make symlink for shared uploads"
|
12
|
+
task :symlink do
|
13
|
+
run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
Capistrano::Configuration.instance.load do
|
5
|
+
#
|
6
|
+
# Capistrano sync.rb task to sync kuhsaft databas.
|
7
|
+
#
|
8
|
+
namespace :sync do
|
9
|
+
namespace :down do
|
10
|
+
namespace :kuhsaft do
|
11
|
+
desc <<-DESC
|
12
|
+
Syncs database from the selected mutli_stage environment to the local develoment environment.
|
13
|
+
The database credentials will be read from your local config/database.yml file and a copy of the
|
14
|
+
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
15
|
+
declared in the sync_backups variable and defaults to 5.
|
16
|
+
DESC
|
17
|
+
task :db, :roles => :db, :only => { :primary => true } do
|
18
|
+
# Use production on non-multistage
|
19
|
+
set :stage, 'production' unless exists?(:stage)
|
20
|
+
|
21
|
+
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
22
|
+
on_rollback { delete "#{shared_path}/sync/#{filename}" }
|
23
|
+
|
24
|
+
# Remote DB dump
|
25
|
+
username, password, database, host = remote_database_config(stage)
|
26
|
+
host_option = host ? "--host='#{host}'" : ""
|
27
|
+
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|
|
28
|
+
puts data
|
29
|
+
end
|
30
|
+
purge_old_backups "database"
|
31
|
+
|
32
|
+
# Download dump
|
33
|
+
download "#{shared_path}/sync/#{filename}", filename
|
34
|
+
|
35
|
+
# Local DB import
|
36
|
+
username, password, database, host = database_config('development')
|
37
|
+
run_locally "rake db:drop && rake db:create"
|
38
|
+
run_locally "bzip2 -d -c #{filename} | mysql -u #{username} --password='#{password}' #{database}"
|
39
|
+
run_locally "rm -f #{filename}"
|
40
|
+
|
41
|
+
logger.important "sync database from the stage '#{stage}' to local finished"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :up do
|
47
|
+
namespace :kuhsaft do
|
48
|
+
desc <<-DESC
|
49
|
+
Syncs database from the local develoment environment to the selected mutli_stage environement.
|
50
|
+
The database credentials will be read from your local config/database.yml file and a copy of the
|
51
|
+
dump will be kept within the shared sync directory. The amount of backups that will be kept is
|
52
|
+
declared in the sync_backups variable and defaults to 5.
|
53
|
+
DESC
|
54
|
+
task :db, :roles => :db, :only => { :primary => true } do
|
55
|
+
# Use production on non-multistage
|
56
|
+
set :stage, 'production' unless exists?(:stage)
|
57
|
+
|
58
|
+
filename = "database.kuhsaft.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
59
|
+
|
60
|
+
on_rollback do
|
61
|
+
delete "#{shared_path}/sync/#{filename}"
|
62
|
+
run_locally "rm -f #{filename}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# Make a backup before importing
|
66
|
+
username, password, database, host = remote_database_config(stage)
|
67
|
+
host_option = host ? "--host='#{host}'" : ""
|
68
|
+
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|
|
69
|
+
puts data
|
70
|
+
end
|
71
|
+
|
72
|
+
# Local DB export
|
73
|
+
filename = "dump.local.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
74
|
+
username, password, database, host = database_config('development')
|
75
|
+
host_option = host ? "--host='#{host}'" : ""
|
76
|
+
run_locally "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{filename}"
|
77
|
+
upload filename, "#{shared_path}/sync/#{filename}"
|
78
|
+
run_locally "rm -f #{filename}"
|
79
|
+
|
80
|
+
# Remote DB import
|
81
|
+
username, password, database, host = remote_database_config(stage)
|
82
|
+
host_option = host ? "--host='#{host}'" : ""
|
83
|
+
run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}"
|
84
|
+
run "rm -f #{shared_path}/sync/#{filename}"
|
85
|
+
purge_old_backups "database.kuhsaft"
|
86
|
+
|
87
|
+
logger.important "sync database from local to the stage '#{stage}' finished"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), '/sync/*.rb')).sort.each { |f| require f }
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
#
|
3
|
+
# Capistrano task for syncing directories.
|
4
|
+
#
|
5
|
+
namespace :sync do
|
6
|
+
namespace :down do
|
7
|
+
desc <<-DESC
|
8
|
+
Sync declared directories from the selected multi_stage environment to the local development
|
9
|
+
environment. The synced directories must be declared as an array of Strings with the sync_directories
|
10
|
+
variable. The path is relative to the shared path.
|
11
|
+
DESC
|
12
|
+
task :fs, :roles => :web, :once => true do
|
13
|
+
# Use production on non-multistage
|
14
|
+
set :stage, 'production' unless exists?(:stage)
|
15
|
+
|
16
|
+
server, port = host_and_port
|
17
|
+
|
18
|
+
Array(fetch(:sync_directories, [])).each do |syncdir|
|
19
|
+
unless File.directory? "#{syncdir}"
|
20
|
+
logger.info "create local '#{syncdir}' folder"
|
21
|
+
Dir.mkdir "#{syncdir}"
|
22
|
+
end
|
23
|
+
logger.info "sync #{syncdir} from #{server}:#{port} to local"
|
24
|
+
destination, base = Pathname.new(syncdir).split
|
25
|
+
run_locally "rsync --verbose --archive --compress --copy-links --delete --stats --rsh='ssh -p #{port}' #{user}@#{server}:#{shared_path}/#{syncdir} #{destination.to_s}"
|
26
|
+
end
|
27
|
+
|
28
|
+
logger.important "sync filesystem from the stage '#{stage}' to local finished"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
namespace :up do
|
33
|
+
desc <<-DESC
|
34
|
+
Sync declared directories from the local development environement to the selected multi_stage
|
35
|
+
environment. The synced directories must be declared as an array of Strings with the sync_directories
|
36
|
+
variable. The path is relative to the shared path.
|
37
|
+
DESC
|
38
|
+
task :fs, :roles => :web, :once => true do
|
39
|
+
# Use production on non-multistage
|
40
|
+
set :stage, 'production' unless exists?(:stage)
|
41
|
+
|
42
|
+
server, port = host_and_port
|
43
|
+
Array(fetch(:sync_directories, [])).each do |syncdir|
|
44
|
+
destination, base = Pathname.new(syncdir).split
|
45
|
+
if File.directory? "#{syncdir}"
|
46
|
+
# Make a backup
|
47
|
+
logger.info "backup #{syncdir}"
|
48
|
+
run "tar cjf #{shared_path}/sync/#{base}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.tar.bz2 #{shared_path}/#{syncdir}"
|
49
|
+
purge_old_backups "#{base}"
|
50
|
+
else
|
51
|
+
logger.info "Create '#{syncdir}' directory"
|
52
|
+
run "mkdir #{current_path}/#{syncdir}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Sync directory up
|
56
|
+
logger.info "sync #{syncdir} to #{server}:#{port} from local"
|
57
|
+
run_locally "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir} #{user}@#{server}:#{shared_path}/#{destination.to_s}"
|
58
|
+
end
|
59
|
+
logger.important "sync filesystem from local to the stage '#{stage}' finished"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
#
|
3
|
+
# Capistrano task for syncing data between the
|
4
|
+
# local development environment and different multi_stage environments. You
|
5
|
+
# cannot sync directly between two multi_stage environments, always use your
|
6
|
+
# local machine as loop way.
|
7
|
+
#
|
8
|
+
# Based on code by Michael Kessler aka netzpirat, sponsored by Screen Concept, www.screenconcept.ch
|
9
|
+
#
|
10
|
+
# Released under the MIT license.
|
11
|
+
#
|
12
|
+
namespace :sync do
|
13
|
+
after "deploy:setup", "sync:setup"
|
14
|
+
|
15
|
+
desc <<-DESC
|
16
|
+
Creates the sync dir in shared path. The sync directory is used to keep
|
17
|
+
backups of database dumps and archives from synced directories. This task will
|
18
|
+
be called on 'deploy:setup'
|
19
|
+
DESC
|
20
|
+
task :setup do
|
21
|
+
run "mkdir -p #{shared_path}/sync"
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :down do
|
25
|
+
desc <<-DESC
|
26
|
+
Syncs data from the selected multi_stage environment to the local development environment.
|
27
|
+
This task calls all tasks in the 'sync:down' namespace.
|
28
|
+
DESC
|
29
|
+
task :default do
|
30
|
+
subtasks = task_list(true) - [current_task]
|
31
|
+
subtasks.map{|task| execute_task(task)}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
namespace :up do
|
36
|
+
desc <<-DESC
|
37
|
+
Syncs data from the local development environment to the selected multi_stage environment.
|
38
|
+
This task calls all tasks in the 'sync:up' namespace.
|
39
|
+
DESC
|
40
|
+
task :default do
|
41
|
+
subtasks = task_list(true) - [current_task]
|
42
|
+
subtasks.map{|task| execute_task(task)}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Purge old backups within the shared sync directory
|
48
|
+
#
|
49
|
+
def purge_old_backups(base)
|
50
|
+
count = fetch(:sync_backups, 5).to_i
|
51
|
+
backup_files = capture("ls -xt #{shared_path}/sync/#{base}*").split.reverse
|
52
|
+
if count >= backup_files.length
|
53
|
+
logger.important "no old backups to clean up"
|
54
|
+
else
|
55
|
+
logger.info "keeping #{count} of #{backup_files.length} sync backups"
|
56
|
+
delete_backups = (backup_files - backup_files.last(count)).join(" ")
|
57
|
+
try_sudo "rm -rf #{delete_backups}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capones_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 11
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Roman Simecek (CyT)
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
19
|
+
date: 2011-12-06 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -143,12 +143,17 @@ files:
|
|
143
143
|
- lib/capones_recipes/tasks/deploy_targets.rb
|
144
144
|
- lib/capones_recipes/tasks/email.rb
|
145
145
|
- lib/capones_recipes/tasks/kuhsaft.rb
|
146
|
+
- lib/capones_recipes/tasks/kuhsaft/kuhsaft.rb
|
147
|
+
- lib/capones_recipes/tasks/kuhsaft/sync.rb
|
146
148
|
- lib/capones_recipes/tasks/new_relic.rb
|
147
149
|
- lib/capones_recipes/tasks/rails.rb
|
148
150
|
- lib/capones_recipes/tasks/rails/database_yml.rb
|
149
151
|
- lib/capones_recipes/tasks/rails/logs.rb
|
150
152
|
- lib/capones_recipes/tasks/restful_authentication.rb
|
151
153
|
- lib/capones_recipes/tasks/settings_logic.rb
|
154
|
+
- lib/capones_recipes/tasks/sync.rb
|
155
|
+
- lib/capones_recipes/tasks/sync/fs.rb
|
156
|
+
- lib/capones_recipes/tasks/sync/sync.rb
|
152
157
|
- lib/capones_recipes/tasks/thinking_sphinx.rb
|
153
158
|
- lib/capones_recipes/tasks/utilities.rb
|
154
159
|
- lib/capones_recipes/version.rb
|