File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def decompress(from, to = nil)
32
32
"-c --stdout > #{ to } "
33
33
end
34
34
35
- "bunzip2 -f #{ from } #{ to } "
35
+ "bunzip2 -k - f #{ from } #{ to } "
36
36
end
37
37
38
38
end
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ def initialize(cap_instance)
112
112
113
113
def dump
114
114
@cap . execute "cd #{ @cap . current_path } && #{ dump_cmd } | #{ compressor . compress ( '-' , output_file ) } "
115
+ @cap . execute ( "ln -fs #{ @cap . current_path } /#{ output_file } #{ @cap . current_path } /db/latest.sql.#{ compressor . file_extension } " )
115
116
self
116
117
end
117
118
@@ -212,6 +213,11 @@ def backup(instance)
212
213
remote_db = Database ::Remote . new ( instance )
213
214
remote_db . dump
214
215
end
216
+
217
+ def restore_latest ( instance )
218
+ remote_db = Database ::Remote . new ( instance )
219
+ remote_db . load ( "#{ instance . current_path } /db/latest.sql.#{ remote_db . compressor . file_extension } " , true )
220
+ end
215
221
end
216
222
217
223
end
Original file line number Diff line number Diff line change 37
37
Database . backup ( self )
38
38
end
39
39
end
40
+
41
+ desc 'Restores the latest database dump from the remote folder (pairs with db:remote:backup)'
42
+ task :restore_latest do
43
+ on roles ( :db ) do
44
+ Database . restore_latest ( self )
45
+ end
46
+ end
40
47
end
41
48
42
49
namespace :local do
You can’t perform that action at this time.
0 commit comments