do_snapshot 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7053ccac28ae155fac055356c0e2ef2e95373ffb
4
- data.tar.gz: d315d1e4faa88f2b6562b64ab79d8480e01e25c5
3
+ metadata.gz: d46f25363b39fbfdbe390c2fe585a0a859414f39
4
+ data.tar.gz: 1163c72711dc3ccd58b21444bf0b65d75184e255
5
5
  SHA512:
6
- metadata.gz: 77ca8773db485352055ca4118661451bcf1c55a538e248de7e7ed3eb44e6e8e5d6314ebb66645ed54f57f4fb31c76a21993000b1f97cc0f01223195cb3daeb80
7
- data.tar.gz: 7d91bb1e124c979af67c26aed36c31e4d3e1d0f958b1ac01ca1f8e122fe8dba8e8e9e2585c1cd4d4973855e572470df7c7ea1a047b5b8e54c2fa754a3e80612a
6
+ metadata.gz: 5ac384653b71a000fa1511fcc84bb9233aef285320fc5bcfc76d516f75c087790f7c415fd95eeda5175eb4e09636ff1b86ed9595884d08d6c685dade01d3f90e
7
+ data.tar.gz: 3409ab059c16d04d4b404dc48a189e6f2c3e7623aed528fad52f8680079d9f746271911eb33a49d1b912cc94773547f600d98ef5ad39afc7f5c3181a01362a83
data/README.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # DoSnapshot
2
2
 
3
- TODO: Write a gem description
3
+ You can use this gem to backup's DigitalOcean droplet's via snapshot.
4
+
5
+ Here some features:
6
+
7
+ - Binary for cron and command-line.
8
+ - Mail notification when maximum of snapshots for droplet reached.
9
+ - Custom mail settings (You can set [Pony](https://github.com/benprew/pony) mail settings).
10
+ - Stop mode (when you don't want to create new snapshots when maximum is reached).
11
+ - Logging into selected directory.
12
+ - Trace mode for research.
13
+ - Quiet mode for silence.
14
+
15
+ There not so much of dependencies:
16
+
17
+ - `Digitalocean` for API requests.
18
+ - `Thor` for CLI.
19
+ - `Pony` for mail notifications.
4
20
 
5
21
  ## Installation
6
22
 
@@ -18,7 +34,61 @@ Or install it yourself as:
18
34
 
19
35
  ## Usage
20
36
 
21
- TODO: Write usage instructions here
37
+ First you may need to set DigitalOcean API keys:
38
+
39
+ ```shell
40
+ export DIGITAL_OCEAN_CLIENT_ID = "SOMEID"
41
+ export DIGITAL_OCEAN_API_KEY = "SOMEKEY"
42
+ ```
43
+
44
+ If you want to set keys without environment, than set it via options:
45
+
46
+ ```shell
47
+ do_snapshot --digital-ocean-client-id YOURLONGAPICLIENTID --digital-ocean-api-key YOURLONGAPIKEY
48
+ ```
49
+
50
+ E-mail notifications disabled out of the box.
51
+ For working mailer you need to set e-mail settings via run options.
52
+
53
+ ```shell
54
+ Usage:
55
+ do_snapshot create
56
+
57
+ Options:
58
+ -o, [--only=123456 123456 123456] # Use only selected droplets.
59
+ -e, [--exclude=123456 123456 123456] # Except some droplets.
60
+ -k, [--keep=5] # How much snapshots you want to keep?
61
+ # Default: 10
62
+ -s, [--stop], [--no-stop] # Stop creating snapshots if maximum is reached.
63
+ -m, [--mail=to:yourmail@example.com] # Receive mail if maximum is reached.
64
+ -t, [--smtp=user_name:yourmail@example.com password:password] # SMTP options.
65
+ -l, [--log=/Users/someone/.do_snapshot/main.log] # Log file path. By default logging is disabled.
66
+ -d, [--trace], [--no-trace] # Debug mode.
67
+ -q, [--quiet], [--no-quiet] # Quiet mode. If don't need any messages and log's
68
+ [--digital-ocean-client-id=YOURLONGAPICLIENTID] # DIGITAL_OCEAN_CLIENT_ID. if you can't use environment.
69
+ [--digital-ocean-api-key=YOURLONGAPIKEY] # DIGITAL_OCEAN_API_KEY. if you can't use environment.
70
+
71
+ Description:
72
+ `do_snapshot create` will create and cleanup snapshots on your droplets.
73
+
74
+ You can optionally specify parameters to select or exclude some droplets.
75
+
76
+ Advanced options example for MAIL feature:
77
+
78
+ --mail to:mail@somehost.com from:from@host.com --smtp address:smtp.gmail.com user_name:someuser password:somepassword
79
+
80
+ For more details look here: [https://github.com/benprew/pony](https://github.com/benprew/pony)
81
+
82
+ Example:
83
+
84
+ > $ do_snapshot --keep 5 --quiet
85
+
86
+ > $ do_snapshot --only 123456 1234567 --store 3
87
+
88
+ > $ do_snapshot --exclude 123456 123457
89
+
90
+ > $ do_snapshot --keep 10 --stop true --mail to:yourmail@example.com
91
+ ```
22
92
 
23
93
  ## Contributing
24
94
 
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 runner for Digital Ocean droplets. Use it with Cron or other tools.}
12
- spec.description = %q{Snapshot runner for Digital Ocean droplets. Use it with Cron or other tools.}
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.}
13
13
  spec.homepage = 'http://github.com/merqlove/do_snapshot'
14
14
  spec.license = 'MIT'
15
15
 
@@ -10,11 +10,19 @@ module DoSnapshot
10
10
 
11
11
  def initialize(*args)
12
12
  super
13
- if options.include? 'log'
13
+
14
+ # Use Thor log especially
15
+ Log.thor_log = Thor::Shell::Color.new unless options.include?('quiet')
16
+
17
+ if options.include?('log')
14
18
  Log.logger = Logger.new(options['log'])
15
- Log.thor_log = Thor::Shell::Color.new
16
19
  Log.logger.level = options.include?('trace') ? Logger::DEBUG : Logger::INFO
17
20
  end
21
+
22
+ # Check for keys via options
23
+ ENV['DIGITAL_OCEAN_CLIENT_ID'] = options['digital_ocean_client_id'] if options.include? 'digital_ocean_client_id'
24
+ ENV['DIGITAL_OCEAN_API_KEY'] = options['digital_ocean_api_key'] if options.include? 'digital_ocean_api_key'
25
+
18
26
  try_keys_first
19
27
  end
20
28
 
@@ -43,13 +51,17 @@ module DoSnapshot
43
51
  option :only, type: :array, default: [], aliases: ['-o'], banner: '123456 123456 123456', desc: 'Use only selected droplets.'
44
52
  option :exclude, type: :array, default: [], aliases: ['-e'], banner: '123456 123456 123456', desc: 'Except some droplets.'
45
53
  option :keep, type: :numeric, default: 10, aliases: ['-k'], banner: '5', desc: 'How much snapshots you want to keep?'
46
- option :stop, type: :boolean, aliases: ['-s'], banner: 'true', desc: 'Stop creating snapshots if maximum is reached.'
54
+ option :stop, type: :boolean, aliases: ['-s'], desc: 'Stop creating snapshots if maximum is reached.'
47
55
  option :mail, type: :hash, default: {}, aliases: ['-m'], banner: 'to:yourmail@example.com', desc: 'Receive mail if maximum is reached.'
48
56
  option :smtp, type: :hash, default: {}, aliases: ['-t'], banner: 'user_name:yourmail@example.com password:password', desc: 'SMTP options.'
49
57
  option :log, type: :string, aliases: ['-l'], banner: '/Users/someone/.do_snapshot/main.log', desc: 'Log file path. By default logging is disabled.'
50
- option :trace, type: :boolean, aliases: ['-d'], desc: 'Debug mode. Not implented now. Switched only log mode.'
58
+ option :trace, type: :boolean, aliases: ['-d'], desc: 'Debug mode.'
59
+ option :quiet, type: :boolean, aliases: ['-q'], desc: 'Quiet mode. If don\'t need any messages and log\'s'
60
+ option :digital_ocean_client_id, type: :string, banner: 'YOURLONGAPICLIENTID', desc: 'DIGITAL_OCEAN_CLIENT_ID. if you can\'t use environment.'
61
+ option :digital_ocean_api_key, type: :string, banner: 'YOURLONGAPIKEY', desc: 'DIGITAL_OCEAN_API_KEY. if you can\'t use environment.'
62
+
51
63
  def create
52
- DoSnapshot::Command.execute options, %w( log trace )
64
+ DoSnapshot::Command.execute options, %w( log trace quiet digital_ocean_client_id digital_ocean_api_key )
53
65
  rescue => e
54
66
  Log.error e.message
55
67
  backtrace(e) if options.include? 'trace'
@@ -63,11 +75,11 @@ module DoSnapshot
63
75
  end
64
76
  end
65
77
 
66
- # Check DigitalOcean API keys
78
+ # Check for DigitalOcean API keys
67
79
  def try_keys_first
68
80
  Log.debug 'Checking DigitalOcean Id\'s.'
69
- fail Thor::Error, 'You must have DIGITAL_OCEAN_CLIENT_ID in environment.' if !ENV['DIGITAL_OCEAN_CLIENT_ID'] || ENV['DIGITAL_OCEAN_CLIENT_ID'].empty?
70
- fail Thor::Error, 'You must have DIGITAL_OCEAN_API_KEY in environment.' if !ENV['DIGITAL_OCEAN_API_KEY'] || ENV['DIGITAL_OCEAN_API_KEY'].empty?
81
+ fail Thor::Error, 'You must have DIGITAL_OCEAN_CLIENT_ID in environment or set via options.' if !ENV['DIGITAL_OCEAN_CLIENT_ID'] || ENV['DIGITAL_OCEAN_CLIENT_ID'].empty?
82
+ fail Thor::Error, 'You must have DIGITAL_OCEAN_API_KEY in environment or set via options.' if !ENV['DIGITAL_OCEAN_API_KEY'] || ENV['DIGITAL_OCEAN_API_KEY'].empty?
71
83
  end
72
84
  end
73
85
  end
@@ -1,5 +1,5 @@
1
1
  # Current version
2
2
  #
3
3
  module DoSnapshot
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
data/lib/do_snapshot.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'do_snapshot/version'
2
2
  require 'logger'
3
3
 
4
-
5
4
  # Used primary for creating snapshot's as backups for DigitalOcean
6
5
  #
7
6
  module DoSnapshot
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Merkulov
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Snapshot runner for Digital Ocean droplets. Use it with Cron or other
83
+ description: Snapshot creator for Digital Ocean droplets. Use it with Cron or other
84
84
  tools.
85
85
  email:
86
86
  - sasha@merqlove.ru
@@ -127,6 +127,6 @@ rubyforge_project:
127
127
  rubygems_version: 2.2.2
128
128
  signing_key:
129
129
  specification_version: 4
130
- summary: Snapshot runner for Digital Ocean droplets. Use it with Cron or other tools.
130
+ summary: Snapshot creator for Digital Ocean droplets. Use it with Cron or other tools.
131
131
  test_files:
132
132
  - test/.keep