do_snapshot 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/do_snapshot.gemspec +2 -2
- data/lib/do_snapshot/command.rb +20 -8
- data/lib/do_snapshot/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c4999ce47e4ce7b2466c14205933af0cbdc961
|
4
|
+
data.tar.gz: 0403072d2dd494b8f03090e7c4b7624414c9d7b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9866805ad171483316b5dd4fbb1e674dff9d779b097e23757167af90f99cb4acd39fd9827b1fbe3d52a5f4a8aae06578c49fa81ad9defea6f535be4183bb26
|
7
|
+
data.tar.gz: 5ac4d9c275029df7a2300c258ba7b75268657353e906c01cfc375189a12c4d5be64e27253bb49e52df39a5656e67259f126ca28c4659a58a78cc5922837c6eee
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ You can use this gem to backup's DigitalOcean droplet's via snapshot.
|
|
4
4
|
|
5
5
|
Here some features:
|
6
6
|
|
7
|
+
- Multiple threads out of the box.
|
7
8
|
- Binary for cron and command-line.
|
8
9
|
- Mail notification when maximum of snapshots for droplet reached.
|
9
10
|
- Custom mail settings (You can set [Pony](https://github.com/benprew/pony) mail settings).
|
data/do_snapshot.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = DoSnapshot::VERSION
|
9
9
|
spec.authors = ['Alexander Merkulov']
|
10
10
|
spec.email = ['sasha@merqlove.ru']
|
11
|
-
spec.summary = %q{Snapshot creator for Digital Ocean droplets. Use it with Cron or other tools.}
|
12
|
-
spec.description = %q{Snapshot creator for Digital Ocean droplets. Use it with Cron or other tools.}
|
11
|
+
spec.summary = %q{Snapshot creator for Digital Ocean droplets. Multi-threading inside. Use it with Cron or other tools.}
|
12
|
+
spec.description = %q{Snapshot creator for Digital Ocean droplets. Multi-threading inside. Use it with Cron or other tools.}
|
13
13
|
spec.homepage = 'http://github.com/merqlove/do_snapshot'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
data/lib/do_snapshot/command.rb
CHANGED
@@ -2,6 +2,7 @@ require 'digitalocean'
|
|
2
2
|
require 'date'
|
3
3
|
require 'pony'
|
4
4
|
require 'core_ext/hash'
|
5
|
+
require 'thread'
|
5
6
|
|
6
7
|
module DoSnapshot
|
7
8
|
# Our commands live here :)
|
@@ -15,7 +16,8 @@ module DoSnapshot
|
|
15
16
|
send("#{key}=", option) unless skip.include? key
|
16
17
|
end
|
17
18
|
|
18
|
-
self.notify
|
19
|
+
self.notify = false
|
20
|
+
self.threads = []
|
19
21
|
|
20
22
|
work_droplets
|
21
23
|
email_message if notify && mail
|
@@ -33,6 +35,7 @@ module DoSnapshot
|
|
33
35
|
attr_accessor :smtp
|
34
36
|
attr_accessor :stop
|
35
37
|
attr_accessor :notify
|
38
|
+
attr_accessor :threads
|
36
39
|
|
37
40
|
# Getting droplets list from API.
|
38
41
|
# And store into object.
|
@@ -60,6 +63,13 @@ module DoSnapshot
|
|
60
63
|
|
61
64
|
prepare_instance instance.droplet
|
62
65
|
end
|
66
|
+
thread_chain
|
67
|
+
end
|
68
|
+
|
69
|
+
# Threads review
|
70
|
+
#
|
71
|
+
def thread_chain
|
72
|
+
threads.each {|t| t.join}
|
63
73
|
end
|
64
74
|
|
65
75
|
# Preparing instance to take snapshot.
|
@@ -79,15 +89,17 @@ module DoSnapshot
|
|
79
89
|
|
80
90
|
# Stopping instance.
|
81
91
|
Log.debug 'Shutting down droplet.'
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
threads << Thread.new do
|
93
|
+
unless instance.status.include? 'off'
|
94
|
+
event = Digitalocean::Droplet.power_off(instance.id)
|
95
|
+
if event.status.include? 'OK'
|
96
|
+
sleep 1.3 until get_event_status(event.event_id)
|
97
|
+
end
|
86
98
|
end
|
87
|
-
end
|
88
99
|
|
89
|
-
|
90
|
-
|
100
|
+
# Create snapshot.
|
101
|
+
create_snapshot instance, warning_size
|
102
|
+
end
|
91
103
|
end
|
92
104
|
|
93
105
|
# Trying to create a snapshot.
|
data/lib/do_snapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do_snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Merkulov
|
@@ -80,8 +80,8 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: Snapshot creator for Digital Ocean droplets.
|
84
|
-
tools.
|
83
|
+
description: Snapshot creator for Digital Ocean droplets. Multi-threading inside.
|
84
|
+
Use it with Cron or other tools.
|
85
85
|
email:
|
86
86
|
- sasha@merqlove.ru
|
87
87
|
executables:
|
@@ -127,6 +127,7 @@ rubyforge_project:
|
|
127
127
|
rubygems_version: 2.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
|
-
summary: Snapshot creator for Digital Ocean droplets.
|
130
|
+
summary: Snapshot creator for Digital Ocean droplets. Multi-threading inside. Use
|
131
|
+
it with Cron or other tools.
|
131
132
|
test_files:
|
132
133
|
- test/.keep
|