shelly 0.2.25 → 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/shelly/app.rb +6 -4
- data/lib/shelly/cli/backup.rb +5 -5
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/cli/backup_spec.rb +8 -6
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.2.26 / 2013-06-10
|
2
|
+
* [bug] `shelly backup import` now actually compresses the file (bzip2 is used)
|
3
|
+
* [improvement] `shelly backup import` also accepts path to dump file
|
4
|
+
|
1
5
|
## 0.2.25 / 2013-06-06
|
2
6
|
|
3
7
|
* [feature] It's possible to import PostgreSQL and MongoDB database from a dump file with `shelly backup import KIND FILENAME`. See our documentation for more info https://shellycloud.com/documentation/database_backups#import_database
|
data/lib/shelly/app.rb
CHANGED
@@ -120,8 +120,9 @@ module Shelly
|
|
120
120
|
shelly.restore_backup(code_name, filename)
|
121
121
|
end
|
122
122
|
|
123
|
-
def import_database(kind, filename)
|
124
|
-
ssh(:command => "import_database #{kind} #{filename}"
|
123
|
+
def import_database(kind, filename, server)
|
124
|
+
ssh(:command => "import_database #{kind} #{filename}",
|
125
|
+
:server => server)
|
125
126
|
end
|
126
127
|
|
127
128
|
def request_backup(kinds)
|
@@ -248,8 +249,9 @@ module Shelly
|
|
248
249
|
end
|
249
250
|
|
250
251
|
def upload(source)
|
251
|
-
|
252
|
-
|
252
|
+
console_connection.tap do |conn|
|
253
|
+
rsync(source, "#{conn['host']}:/srv/glusterfs/disk")
|
254
|
+
end
|
253
255
|
end
|
254
256
|
|
255
257
|
def download(relative_source, destination)
|
data/lib/shelly/cli/backup.rb
CHANGED
@@ -103,7 +103,7 @@ module Shelly
|
|
103
103
|
long_desc %{
|
104
104
|
Import database from local dump file to your cloud
|
105
105
|
KIND - Database kind. Possible values are: postgresql or mongodb
|
106
|
-
FILENAME - Database dump file or directory (mongodb)
|
106
|
+
FILENAME - Database dump file or directory (mongodb)
|
107
107
|
}
|
108
108
|
def import(kind, filename)
|
109
109
|
app = multiple_clouds(options[:cloud], "backup import KIND FILENAME")
|
@@ -114,18 +114,18 @@ module Shelly
|
|
114
114
|
ask_to_import_database
|
115
115
|
archive = compress(filename)
|
116
116
|
say "Uploading #{archive}", :green
|
117
|
-
app.upload(archive)
|
117
|
+
connection = app.upload(archive)
|
118
118
|
say "Uploading done", :green
|
119
119
|
say "Importing database", :green
|
120
|
-
app.import_database(kind, archive)
|
120
|
+
app.import_database(kind, archive, connection["server"])
|
121
121
|
say "Database imported successfully", :green
|
122
122
|
end
|
123
123
|
|
124
124
|
no_tasks do
|
125
125
|
def compress(filename)
|
126
|
-
archive_name = "#{::File.basename(filename)}.tar"
|
126
|
+
archive_name = "#{::File.basename(filename)}-#{Time.now.to_i}.tar.bz2"
|
127
127
|
say "Compressing #{filename} into #{archive_name}", :green
|
128
|
-
system("tar -
|
128
|
+
system("tar -cjf #{archive_name} #{filename}")
|
129
129
|
archive_name
|
130
130
|
end
|
131
131
|
end
|
data/lib/shelly/version.rb
CHANGED
@@ -255,10 +255,11 @@ describe Shelly::CLI::Backup do
|
|
255
255
|
describe "#import" do
|
256
256
|
before do
|
257
257
|
FileUtils.touch("dump.sql")
|
258
|
-
@app.stub(:upload =>
|
258
|
+
@app.stub(:upload => {"server" => "app1"}, :ssh => nil)
|
259
259
|
@backup.stub(:system)
|
260
260
|
$stdout.stub(:puts)
|
261
261
|
$stdout.stub(:print)
|
262
|
+
Time.stub_chain(:now, :to_i => 1370879705)
|
262
263
|
end
|
263
264
|
|
264
265
|
it "should ensure user has logged in" do
|
@@ -266,23 +267,24 @@ describe Shelly::CLI::Backup do
|
|
266
267
|
end
|
267
268
|
|
268
269
|
it "should compress file" do
|
269
|
-
@backup.should_receive(:system).with("tar -
|
270
|
-
$stdout.should_receive(:puts).with(green "Compressing dump.sql into dump.sql.tar")
|
270
|
+
@backup.should_receive(:system).with("tar -cjf dump.sql-1370879705.tar.bz2 dump.sql")
|
271
|
+
$stdout.should_receive(:puts).with(green "Compressing dump.sql into dump.sql-1370879705.tar.bz2")
|
271
272
|
fake_stdin(["yes"]) do
|
272
273
|
invoke(@backup, :import, "postgresql", "dump.sql")
|
273
274
|
end
|
274
275
|
end
|
275
276
|
|
276
277
|
it "should upload compressed file" do
|
277
|
-
@app.should_receive(:upload).with("dump.sql.tar")
|
278
|
-
$stdout.should_receive(:puts).with(green "Uploading dump.sql.tar")
|
278
|
+
@app.should_receive(:upload).with("dump.sql-1370879705.tar.bz2")
|
279
|
+
$stdout.should_receive(:puts).with(green "Uploading dump.sql-1370879705.tar.bz2")
|
279
280
|
fake_stdin(["yes"]) do
|
280
281
|
invoke(@backup, :import, "postgresql", "dump.sql")
|
281
282
|
end
|
282
283
|
end
|
283
284
|
|
284
285
|
it "should import given database from uploaded file" do
|
285
|
-
@app.should_receive(:ssh).with(:command => "import_database postgresql dump.sql.tar"
|
286
|
+
@app.should_receive(:ssh).with(:command => "import_database postgresql dump.sql-1370879705.tar.bz2",
|
287
|
+
:server => "app1")
|
286
288
|
$stdout.should_receive(:puts).with(green "Importing database")
|
287
289
|
fake_stdin(["yes"]) do
|
288
290
|
invoke(@backup, :import, "postgresql", "dump.sql")
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.26
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Shelly Cloud team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|