41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/bibliotech/rake_lib.rb', line 41
def define
in_namespace do
namespace :backups do
desc "Restore from a named DB backup"
task :restore, [:name] do |task, args|
fail ":name is required" if args[:name].nil?
options = { :backups => { :filename => args[:name] } }
if %r[/] =~ args[:name]
options = { :backups => { :file => args[:name] } }
end
app.import(options)
end
task :create, [:prefix] do |task, args|
options = {}
unless args[:prefix].nil?
options[:backups] = {:prefix => args[:prefix]}
end
app.create_backup(options)
end
task :clean, [:prefix] do |task, args|
options = {}
unless args[:prefix].nil?
options[:backups] = {:prefix => args[:prefix]}
end
app.prune(options)
end
desc "Run DB backups, including cleaning up the resulting backups"
task :perform, [:prefix] => [:create, :clean]
end
namespace :remote_sync do
desc "Pull the latest DB dump from the remote server into our local DB"
task :down do
result = app.remote_cli(remote, "latest")
result.must_succeed!
filename = result.stdout.chomp
app.get(remote, filename).must_succeed!
app.import(:backups => { :file => app.config.local_file(filename)}).must_succeed!
end
desc "Push the latest local DB dump to the remote server's DB"
task :up do
filename = app.latest
app.send(remote, filename).must_succeed!
app.remote_cli(remote, "load", filename).must_succeed!
end
end
end
end
|