dump 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -15
- data/.rubocop_todo.yml +1 -1
- data/Gemfile +6 -1
- data/LICENSE.txt +1 -1
- data/README.markdown +2 -2
- data/dump.gemspec +2 -2
- data/lib/dump.rb +86 -2
- data/lib/{dump_rake/archive_tar_minitar_fix.rb → dump/archive_tar_minitar.rb} +0 -0
- data/lib/{dump_rake → dump}/assets.rb +6 -4
- data/lib/dump/capistrano/v2.rb +34 -34
- data/lib/{dump_rake → dump}/continious_timeout.rb +1 -1
- data/lib/{dump_rake → dump}/env.rb +4 -4
- data/lib/{dump_rake → dump}/env/filter.rb +1 -1
- data/lib/dump/rails_root.rb +19 -0
- data/lib/{dump_rake/dump_reader.rb → dump/reader.rb} +25 -17
- data/lib/{dump_rake/dump.rb → dump/snapshot.rb} +9 -5
- data/lib/{dump_rake → dump}/table_manipulation.rb +28 -14
- data/lib/{dump_rake/dump_writer.rb → dump/writer.rb} +13 -5
- data/lib/tasks/assets.rake +4 -4
- data/lib/tasks/dump.rake +10 -10
- data/script/update_readme +3 -3
- data/spec/cycle_spec.rb +78 -84
- data/spec/{lib/dump_rake → dump}/env/filter_spec.rb +14 -14
- data/spec/dump/env_spec.rb +139 -0
- data/spec/{lib/dump_rake → dump}/rails_root_spec.rb +11 -13
- data/spec/{lib/dump_rake/dump_reader_spec.rb → dump/reader_spec.rb} +89 -89
- data/spec/dump/snapshot_spec.rb +290 -0
- data/spec/{lib/dump_rake → dump}/table_manipulation_spec.rb +54 -55
- data/spec/{lib/dump_rake/dump_writer_spec.rb → dump/writer_spec.rb} +41 -42
- data/spec/dump_spec.rb +327 -0
- data/spec/recipes/dump_spec.rb +92 -93
- data/spec/spec_helper.rb +0 -3
- data/spec/tasks/assets_spec.rb +16 -15
- data/spec/tasks/dump_spec.rb +30 -29
- metadata +75 -98
- data/.autotest +0 -13
- data/lib/dump_rake.rb +0 -94
- data/lib/dump_rake/rails_root.rb +0 -13
- data/spec/lib/dump_rake/dump_spec.rb +0 -289
- data/spec/lib/dump_rake/env_spec.rb +0 -139
- data/spec/lib/dump_rake_spec.rb +0 -326
- data/spec/spec.opts +0 -4
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MjkyOWRmMTZmMGVlNDNlZjUzYzAwMzdkZjAyNWE1MmIyZGQ2MzVmZTMxMjgy
|
10
|
-
MzY1OTBkZTA0ZWIxNTZlMmU1NTE5YTA3MDZkMjM3MjBjNzM3ZWViZGI1Y2U2
|
11
|
-
MDAwNTg4MmE2MzE5YzMwMGY3NDlkMWU2MjY0ZmQyMjkxZjE1OGM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZTQ0ZmVmOWQ0YzVkNzcyMDdiYzQ4ZDI0YTY0YmYzNjczMjlmNDM3ZDBiZDdm
|
14
|
-
YzAzNWI4ODI0OWUzZTE1MGRlMmQ2NWUxYWI2ZWZiMjcyMzY5YzA1OTYwM2Qw
|
15
|
-
YzVmMDc5MzA2NzQ3OTc1NjM4MGYzYTE5ZTczMzc1ZDY1ZWY1ZGQ=
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aeeda9548f8d471316521b37c274e7e5692f9b60
|
4
|
+
data.tar.gz: f15ddf0ed0bc6f906102839da2935fe35a186ca6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3da9dbc8c63515701f19ac328b849fd979d22973da53f82cb826a1b49ee8c4f3bcc5a605f6d93b0a46001d0d5826377565de4ecf2fdb0976732fead37a3389b9
|
7
|
+
data.tar.gz: 82a717b71def2345689c3d13f98cc54790e9a6bdb13f2370293d4dfc46ad63916cc15202945d4ad68d64ca4160a903877349acb40ed7b5bebe47715e263c999b
|
data/.rubocop_todo.yml
CHANGED
data/Gemfile
CHANGED
@@ -10,7 +10,12 @@ if defined?(JRUBY_VERSION)
|
|
10
10
|
else
|
11
11
|
gem 'sqlite3'
|
12
12
|
gem 'mysql2'
|
13
|
-
|
13
|
+
if RUBY_VERSION == '1.8.7'
|
14
|
+
gem 'pg', '0.17.1'
|
15
|
+
gem 'i18n', '0.6.11'
|
16
|
+
else
|
17
|
+
gem 'pg'
|
18
|
+
end
|
14
19
|
if rails_version =~ /(^|[^.\d])(2|3\.0)\.\d+/
|
15
20
|
gem 'activerecord-mysql2-adapter'
|
16
21
|
end
|
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[![Build Status](https://img.shields.io/travis/toy/dump/master.svg?style=flat)](https://travis-ci.org/toy/dump)
|
3
3
|
[![Code Climate](https://img.shields.io/codeclimate/github/toy/dump.svg?style=flat)](https://codeclimate.com/github/toy/dump)
|
4
4
|
|
5
|
-
#
|
5
|
+
# Dump
|
6
6
|
|
7
7
|
Rails app rake and capistrano tasks to create and restore dumps of database and assets.
|
8
8
|
|
@@ -259,4 +259,4 @@ where myappserver.com is application server carrying assets with database access
|
|
259
259
|
|
260
260
|
## Copyright
|
261
261
|
|
262
|
-
Copyright (c) 2008-
|
262
|
+
Copyright (c) 2008-2015 Ivan Kuchin. See LICENSE.txt for details.
|
data/dump.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'dump'
|
5
|
-
s.version = '1.0.
|
5
|
+
s.version = '1.0.6'
|
6
6
|
s.summary = %q{Rails app rake and capistrano tasks to create and restore dumps of database and assets}
|
7
7
|
s.homepage = "http://github.com/toy/#{s.name}"
|
8
8
|
s.authors = ['Ivan Kuchin']
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = %w[lib]
|
17
17
|
|
18
18
|
s.add_dependency 'archive-tar-minitar', '= 0.5.2'
|
19
|
-
s.add_dependency 'progress', '~>
|
19
|
+
s.add_dependency 'progress', '~> 3.0', '>= 3.0.1'
|
20
20
|
s.add_development_dependency 'rspec', '~> 3.0'
|
21
21
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3')
|
22
22
|
s.add_development_dependency 'rubocop', '~> 0.27'
|
data/lib/dump.rb
CHANGED
@@ -1,4 +1,88 @@
|
|
1
|
-
#
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
require 'progress'
|
7
|
+
|
8
|
+
require 'dump/rails_root'
|
9
|
+
require 'dump/snapshot'
|
10
|
+
require 'dump/reader'
|
11
|
+
require 'dump/writer'
|
12
|
+
require 'dump/env'
|
13
|
+
|
14
|
+
require 'dump/railtie' if defined?(Rails::Railtie)
|
15
|
+
|
16
|
+
# Main interface
|
2
17
|
module Dump
|
3
|
-
|
18
|
+
class << self
|
19
|
+
def versions(options = {})
|
20
|
+
Snapshot.list(options).each do |dump|
|
21
|
+
if Dump::Env[:show_size] || $stdout.tty?
|
22
|
+
puts "#{dump.human_size.to_s.rjust(7)}\t#{dump}"
|
23
|
+
else
|
24
|
+
puts dump
|
25
|
+
end
|
26
|
+
begin
|
27
|
+
case options[:summary].to_s.downcase[0, 1]
|
28
|
+
when *%w[1 t y]
|
29
|
+
puts Reader.summary(dump.path)
|
30
|
+
puts
|
31
|
+
when *%w[2 s]
|
32
|
+
puts Reader.summary(dump.path, :schema => true)
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
rescue => e
|
36
|
+
$stderr.puts "Error reading dump: #{e}"
|
37
|
+
$stderr.puts
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def create(options = {})
|
43
|
+
dump = Snapshot.new(options.merge(:dir => File.join(rails_root, 'dump')))
|
44
|
+
|
45
|
+
Writer.create(dump.tmp_path)
|
46
|
+
|
47
|
+
File.rename(dump.tmp_path, dump.tgz_path)
|
48
|
+
puts File.basename(dump.tgz_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def restore(options = {})
|
52
|
+
dump = Snapshot.list(options).last
|
53
|
+
|
54
|
+
if dump
|
55
|
+
Reader.restore(dump.path)
|
56
|
+
else
|
57
|
+
$stderr.puts 'Avaliable versions:'
|
58
|
+
$stderr.puts Snapshot.list
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def cleanup(options = {})
|
63
|
+
unless options[:leave].nil? || /^\d+$/ =~ options[:leave] || options[:leave].downcase == 'none'
|
64
|
+
fail 'LEAVE should be number or "none"'
|
65
|
+
end
|
66
|
+
|
67
|
+
to_delete = []
|
68
|
+
|
69
|
+
all_dumps = Snapshot.list(options.merge(:all => true))
|
70
|
+
to_delete.concat(all_dumps.select{ |dump| dump.ext != 'tgz' })
|
71
|
+
|
72
|
+
dumps = Snapshot.list(options)
|
73
|
+
leave = (options[:leave] || 5).to_i
|
74
|
+
to_delete.concat(dumps[0, dumps.length - leave]) if dumps.length > leave
|
75
|
+
|
76
|
+
to_delete.each do |dump|
|
77
|
+
dump.lock do
|
78
|
+
begin
|
79
|
+
dump.path.unlink
|
80
|
+
puts "Deleted #{dump.path}"
|
81
|
+
rescue => e
|
82
|
+
$stderr.puts "Can not delete #{dump.path} — #{e}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
4
88
|
end
|
File without changes
|
@@ -1,18 +1,20 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require 'dump'
|
4
|
+
|
5
|
+
module Dump
|
4
6
|
# Helper for listing assets for dump
|
5
7
|
module Assets
|
6
8
|
SPLITTER = /[:,]/
|
7
9
|
|
8
10
|
class << self
|
9
11
|
def assets
|
10
|
-
File.readlines(File.join(
|
12
|
+
File.readlines(File.join(Dump.rails_root, 'config/assets')).map(&:strip).grep(/^[^#]/).join(':')
|
11
13
|
end
|
12
14
|
|
13
15
|
def glob_asset_children(asset, glob)
|
14
|
-
path = File.expand_path(asset,
|
15
|
-
if path[0,
|
16
|
+
path = File.expand_path(asset, Dump.rails_root)
|
17
|
+
if path[0, Dump.rails_root.length] == Dump.rails_root # asset must be in rails root
|
16
18
|
Dir[File.join(path, glob)]
|
17
19
|
else
|
18
20
|
[]
|
data/lib/dump/capistrano/v2.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'shellwords'
|
5
5
|
|
6
|
-
require '
|
7
|
-
require '
|
6
|
+
require 'dump/continious_timeout'
|
7
|
+
require 'dump/env'
|
8
8
|
|
9
9
|
require 'active_support/core_ext/object/blank'
|
10
10
|
|
@@ -16,9 +16,9 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
16
16
|
rake = env.delete(:rake) || 'rake'
|
17
17
|
|
18
18
|
# stringify_keys! from activesupport
|
19
|
-
|
19
|
+
Dump::Env.stringify!(env)
|
20
20
|
|
21
|
-
env.update(
|
21
|
+
env.update(Dump::Env.for_command(command, true))
|
22
22
|
|
23
23
|
cmd = %W[-s dump:#{command}]
|
24
24
|
cmd += env.sort.map{ |key, value| "#{key}=#{value}" }
|
@@ -70,7 +70,7 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
when :sftp, :scp
|
73
|
-
|
73
|
+
Dump::ContiniousTimeout.timeout 15 do |thread|
|
74
74
|
transfer(direction, from, to, :via => via) do |_channel, _path, transfered, total|
|
75
75
|
thread.defer
|
76
76
|
progress = if transfered < total
|
@@ -87,7 +87,7 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def do_transfer(direction, from, to)
|
90
|
-
via =
|
90
|
+
via = Dump::Env[:transfer_via]
|
91
91
|
case via && via.downcase
|
92
92
|
when nil
|
93
93
|
if got_rsync?
|
@@ -113,8 +113,8 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def with_additional_tags(*tags)
|
116
|
-
tags = [tags,
|
117
|
-
|
116
|
+
tags = [tags, Dump::Env[:tags]].flatten.select(&:present?).join(',')
|
117
|
+
Dump::Env.with_env(:tags => tags) do
|
118
118
|
yield
|
119
119
|
end
|
120
120
|
end
|
@@ -153,16 +153,16 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def auto_backup?
|
156
|
-
!
|
156
|
+
!Dump::Env.no?(:backup)
|
157
157
|
end
|
158
158
|
|
159
159
|
namespace :local do
|
160
|
-
desc 'Shorthand for dump:local:create' <<
|
160
|
+
desc 'Shorthand for dump:local:create' << Dump::Env.explain_variables_for_command(:create)
|
161
161
|
task :default, :roles => :db, :only => {:primary => true} do
|
162
162
|
local.create
|
163
163
|
end
|
164
164
|
|
165
|
-
desc 'Create local dump' <<
|
165
|
+
desc 'Create local dump' << Dump::Env.explain_variables_for_command(:create)
|
166
166
|
task :create, :roles => :db, :only => {:primary => true} do
|
167
167
|
print_and_return_or_fail do
|
168
168
|
with_additional_tags('local') do
|
@@ -171,24 +171,24 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
desc 'Restore local dump' <<
|
174
|
+
desc 'Restore local dump' << Dump::Env.explain_variables_for_command(:restore)
|
175
175
|
task :restore, :roles => :db, :only => {:primary => true} do
|
176
176
|
run_local(dump_command(:restore))
|
177
177
|
end
|
178
178
|
|
179
|
-
desc 'Versions of local dumps' <<
|
179
|
+
desc 'Versions of local dumps' << Dump::Env.explain_variables_for_command(:versions)
|
180
180
|
task :versions, :roles => :db, :only => {:primary => true} do
|
181
181
|
print run_local(dump_command(:versions, :show_size => true))
|
182
182
|
end
|
183
183
|
|
184
|
-
desc 'Cleanup local dumps' <<
|
184
|
+
desc 'Cleanup local dumps' << Dump::Env.explain_variables_for_command(:cleanup)
|
185
185
|
task :cleanup, :roles => :db, :only => {:primary => true} do
|
186
186
|
print run_local(dump_command(:cleanup))
|
187
187
|
end
|
188
188
|
|
189
|
-
desc 'Upload dump' <<
|
189
|
+
desc 'Upload dump' << Dump::Env.explain_variables_for_command(:transfer)
|
190
190
|
task :upload, :roles => :db, :only => {:primary => true} do
|
191
|
-
file =
|
191
|
+
file = Dump::Env.with_env(:summary => nil) do
|
192
192
|
last_part_of_last_line(run_local(dump_command(:versions)))
|
193
193
|
end
|
194
194
|
if file
|
@@ -198,12 +198,12 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
namespace :remote do
|
201
|
-
desc 'Shorthand for dump:remote:create' <<
|
201
|
+
desc 'Shorthand for dump:remote:create' << Dump::Env.explain_variables_for_command(:create)
|
202
202
|
task :default, :roles => :db, :only => {:primary => true} do
|
203
203
|
remote.create
|
204
204
|
end
|
205
205
|
|
206
|
-
desc 'Create remote dump' <<
|
206
|
+
desc 'Create remote dump' << Dump::Env.explain_variables_for_command(:create)
|
207
207
|
task :create, :roles => :db, :only => {:primary => true} do
|
208
208
|
print_and_return_or_fail do
|
209
209
|
with_additional_tags('remote') do
|
@@ -212,24 +212,24 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
desc 'Restore remote dump' <<
|
215
|
+
desc 'Restore remote dump' << Dump::Env.explain_variables_for_command(:restore)
|
216
216
|
task :restore, :roles => :db, :only => {:primary => true} do
|
217
217
|
run_remote("cd #{current_path}; #{dump_command(:restore, :rake => fetch_rake, :RAILS_ENV => fetch_rails_env, :PROGRESS_TTY => '+')}")
|
218
218
|
end
|
219
219
|
|
220
|
-
desc 'Versions of remote dumps' <<
|
220
|
+
desc 'Versions of remote dumps' << Dump::Env.explain_variables_for_command(:versions)
|
221
221
|
task :versions, :roles => :db, :only => {:primary => true} do
|
222
222
|
print run_remote("cd #{current_path}; #{dump_command(:versions, :rake => fetch_rake, :RAILS_ENV => fetch_rails_env, :PROGRESS_TTY => '+', :show_size => true)}")
|
223
223
|
end
|
224
224
|
|
225
|
-
desc 'Cleanup of remote dumps' <<
|
225
|
+
desc 'Cleanup of remote dumps' << Dump::Env.explain_variables_for_command(:cleanup)
|
226
226
|
task :cleanup, :roles => :db, :only => {:primary => true} do
|
227
227
|
print run_remote("cd #{current_path}; #{dump_command(:cleanup, :rake => fetch_rake, :RAILS_ENV => fetch_rails_env, :PROGRESS_TTY => '+')}")
|
228
228
|
end
|
229
229
|
|
230
|
-
desc 'Download dump' <<
|
230
|
+
desc 'Download dump' << Dump::Env.explain_variables_for_command(:transfer)
|
231
231
|
task :download, :roles => :db, :only => {:primary => true} do
|
232
|
-
file =
|
232
|
+
file = Dump::Env.with_env(:summary => nil) do
|
233
233
|
last_part_of_last_line(run_remote("cd #{current_path}; #{dump_command(:versions, :rake => fetch_rake, :RAILS_ENV => fetch_rails_env, :PROGRESS_TTY => '+')}"))
|
234
234
|
end
|
235
235
|
if file
|
@@ -239,18 +239,18 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
desc 'Shorthand for dump:local:upload' <<
|
242
|
+
desc 'Shorthand for dump:local:upload' << Dump::Env.explain_variables_for_command(:transfer)
|
243
243
|
task :upload, :roles => :db, :only => {:primary => true} do
|
244
244
|
local.upload
|
245
245
|
end
|
246
246
|
|
247
|
-
desc 'Shorthand for dump:remote:download' <<
|
247
|
+
desc 'Shorthand for dump:remote:download' << Dump::Env.explain_variables_for_command(:transfer)
|
248
248
|
task :download, :roles => :db, :only => {:primary => true} do
|
249
249
|
remote.download
|
250
250
|
end
|
251
251
|
|
252
252
|
namespace :mirror do
|
253
|
-
desc 'Creates local dump, uploads and restores on remote' <<
|
253
|
+
desc 'Creates local dump, uploads and restores on remote' << Dump::Env.explain_variables_for_command(:mirror)
|
254
254
|
task :up, :roles => :db, :only => {:primary => true} do
|
255
255
|
auto_backup = if auto_backup?
|
256
256
|
with_additional_tags('auto-backup') do
|
@@ -262,7 +262,7 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
262
262
|
local.create
|
263
263
|
end
|
264
264
|
if file.present?
|
265
|
-
|
265
|
+
Dump::Env.with_clean_env(:like => file) do
|
266
266
|
local.upload
|
267
267
|
remote.restore
|
268
268
|
end
|
@@ -270,7 +270,7 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
desc 'Creates remote dump, downloads and restores on local' <<
|
273
|
+
desc 'Creates remote dump, downloads and restores on local' << Dump::Env.explain_variables_for_command(:mirror)
|
274
274
|
task :down, :roles => :db, :only => {:primary => true} do
|
275
275
|
auto_backup = if auto_backup?
|
276
276
|
with_additional_tags('auto-backup') do
|
@@ -282,7 +282,7 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
282
282
|
remote.create
|
283
283
|
end
|
284
284
|
if file.present?
|
285
|
-
|
285
|
+
Dump::Env.with_clean_env(:like => file) do
|
286
286
|
remote.download
|
287
287
|
local.restore
|
288
288
|
end
|
@@ -292,30 +292,30 @@ Capistrano::Configuration.instance(:i_need_this!).load do
|
|
292
292
|
end
|
293
293
|
|
294
294
|
namespace :backup do
|
295
|
-
desc 'Shorthand for dump:backup:create' <<
|
295
|
+
desc 'Shorthand for dump:backup:create' << Dump::Env.explain_variables_for_command(:backup)
|
296
296
|
task :default, :roles => :db, :only => {:primary => true} do
|
297
297
|
backup.create
|
298
298
|
end
|
299
299
|
|
300
|
-
desc "Creates remote dump and downloads to local (desc defaults to 'backup')" <<
|
300
|
+
desc "Creates remote dump and downloads to local (desc defaults to 'backup')" << Dump::Env.explain_variables_for_command(:backup)
|
301
301
|
task :create, :roles => :db, :only => {:primary => true} do
|
302
302
|
file = with_additional_tags('backup') do
|
303
303
|
remote.create
|
304
304
|
end
|
305
305
|
if file.present?
|
306
|
-
|
306
|
+
Dump::Env.with_clean_env(:like => file) do
|
307
307
|
remote.download
|
308
308
|
end
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
desc 'Uploads dump with backup tag and restores it on remote' <<
|
312
|
+
desc 'Uploads dump with backup tag and restores it on remote' << Dump::Env.explain_variables_for_command(:backup_restore)
|
313
313
|
task :restore, :roles => :db, :only => {:primary => true} do
|
314
314
|
file = with_additional_tags('backup') do
|
315
315
|
last_part_of_last_line(run_local(dump_command(:versions)))
|
316
316
|
end
|
317
317
|
if file.present?
|
318
|
-
|
318
|
+
Dump::Env.with_clean_env(:like => file) do
|
319
319
|
local.upload
|
320
320
|
remote.restore
|
321
321
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'dump/env/filter'
|
4
4
|
|
5
|
-
|
5
|
+
module Dump
|
6
6
|
# Working with environment variables
|
7
7
|
module Env
|
8
8
|
DICTIONARY = {
|
@@ -20,7 +20,7 @@ class DumpRake
|
|
20
20
|
:restore_tables => %w[RESTORE_TABLES],
|
21
21
|
:restore_assets => %w[RESTORE_ASSETS],
|
22
22
|
:show_size => %w[SHOW_SIZE], # internal
|
23
|
-
}.freeze
|
23
|
+
}.freeze
|
24
24
|
|
25
25
|
EXPLANATIONS = {
|
26
26
|
:desc => 'free form description of dump',
|
@@ -36,7 +36,7 @@ class DumpRake
|
|
36
36
|
:restore_schema => 'don\'t read/change schema if you pass "0", "no" or "false" (useful to just restore data for table; note that schema info tables are also not restored)',
|
37
37
|
:restore_tables => 'works as TABLES, but for restoring',
|
38
38
|
:restore_assets => 'works as ASSETS, but for restoring',
|
39
|
-
}.freeze
|
39
|
+
}.freeze
|
40
40
|
|
41
41
|
class << self
|
42
42
|
def with_env(hash)
|