edb 0.2.1 → 0.3
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/Gemfile.lock +18 -2
- data/README.md +8 -0
- data/Rakefile +9 -1
- data/edb.gemspec +3 -0
- data/lib/edb/cryptography.rb +2 -0
- data/lib/edb/dbms.rb +1 -8
- data/lib/edb/dumper.rb +29 -12
- data/lib/edb/is_module_supported.rb +41 -0
- data/lib/edb/storage.rb +2 -0
- data/lib/edb/version.rb +1 -1
- data/lib/edb.rb +1 -0
- data/specs/cryptography_spec.rb +17 -0
- data/specs/dbms_spec.rb +17 -0
- data/specs/spec_helper.rb +1 -0
- data/specs/storage_spec.rb +17 -0
- metadata +34 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b6f5b6e68cdb94dab33d0d94e83adc6db6ad55c
|
4
|
+
data.tar.gz: fb4c730eeebb60a88cf6428e00624aab606d2791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a3fce5eabc34a11d327749015e486f8e9fd60b8a4123afda65aa85aa2f5f73b4a98be2e79a29b21be097f2b258885b013bf6123f5d32a173f27dcc17ae3c32
|
7
|
+
data.tar.gz: fb2e1696ca6554c4a573e8a9e173d033e01cff81ccd48d793390119b32dd9ea6e57a01e077d488ff55dea2fe0cb82a0dcec3a7d4350257b0eff1051bb03916dc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
edb (0.
|
4
|
+
edb (0.3)
|
5
5
|
aws-sdk (= 1.59.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,16 +12,32 @@ GEM
|
|
12
12
|
aws-sdk-v1 (1.59.1)
|
13
13
|
json (~> 1.4)
|
14
14
|
nokogiri (>= 1.4.4)
|
15
|
+
diff-lcs (1.2.5)
|
15
16
|
json (1.8.3)
|
16
17
|
mini_portile (0.6.2)
|
17
18
|
nokogiri (1.6.6.2)
|
18
19
|
mini_portile (~> 0.6.0)
|
20
|
+
rspec (3.3.0)
|
21
|
+
rspec-core (~> 3.3.0)
|
22
|
+
rspec-expectations (~> 3.3.0)
|
23
|
+
rspec-mocks (~> 3.3.0)
|
24
|
+
rspec-core (3.3.2)
|
25
|
+
rspec-support (~> 3.3.0)
|
26
|
+
rspec-expectations (3.3.1)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.3.0)
|
29
|
+
rspec-mocks (3.3.2)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.3.0)
|
32
|
+
rspec-support (3.3.0)
|
19
33
|
|
20
34
|
PLATFORMS
|
21
35
|
ruby
|
22
36
|
|
23
37
|
DEPENDENCIES
|
38
|
+
bundler (~> 1.10)
|
24
39
|
edb!
|
40
|
+
rspec (~> 3.3)
|
25
41
|
|
26
42
|
BUNDLED WITH
|
27
|
-
1.10.
|
43
|
+
1.10.5
|
data/README.md
CHANGED
@@ -18,3 +18,11 @@ Consider also to add *EDB* to your cronjobs.
|
|
18
18
|
- *Cryptography*: `AES_256_CBC`
|
19
19
|
- *DBMS*: `PostgreSQL`, `MySQL`
|
20
20
|
- *Storage*: `S3`, `Filesystem`
|
21
|
+
|
22
|
+
## FAQ
|
23
|
+
**Q:** What if I want to dump two or three MySQL databases?
|
24
|
+
*A:* Just add a `:MySQL:` block for every database you need to dump.
|
25
|
+
|
26
|
+
|
27
|
+
**Q:** What if I want to save a database to S3 and another one into my local filesystem?
|
28
|
+
*A:* Well, you can't. By design, every macro-block (like, `:DBMS:`) is unaware of the other ones. So, for instance, I couldn't ask `:Filesystem:` to work only for the first `:MySQL:` block since it actually does not know what a `:MySQL:` block is. You need just to create two configuration files.
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
task default: [ :build, :install ]
|
4
|
+
task default: [ :build, :install, :test ]
|
5
5
|
|
6
6
|
task :build do
|
7
7
|
sh 'gem build edb.gemspec'
|
@@ -10,3 +10,11 @@ end
|
|
10
10
|
task :install do
|
11
11
|
sh 'gem install *.gem'
|
12
12
|
end
|
13
|
+
|
14
|
+
task :test do
|
15
|
+
FileUtils.cd 'specs' do
|
16
|
+
Dir['*_spec.rb'].each do |spec|
|
17
|
+
sh "rspec #{spec} --backtrace --color --format doc"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/edb.gemspec
CHANGED
data/lib/edb/cryptography.rb
CHANGED
@@ -26,6 +26,8 @@ Dir[File.dirname(__FILE__) + '/cryptography/*.rb'].each { |file| require file }
|
|
26
26
|
module EDB
|
27
27
|
module Cryptography
|
28
28
|
class << self
|
29
|
+
include ::EDB::IsModuleSupported
|
30
|
+
|
29
31
|
def encrypt(method, file)
|
30
32
|
this_module = to_module(method)
|
31
33
|
this_module.encrypt(file)
|
data/lib/edb/dbms.rb
CHANGED
@@ -26,10 +26,7 @@ Dir[File.dirname(__FILE__) + '/dbms/*.rb'].each { |file| require file }
|
|
26
26
|
module EDB
|
27
27
|
module DBMS
|
28
28
|
class << self
|
29
|
-
|
30
|
-
this_module = to_module(dbms)
|
31
|
-
all_modules.include?(this_module)
|
32
|
-
end
|
29
|
+
include ::EDB::IsModuleSupported
|
33
30
|
|
34
31
|
def backup(dbms, *args)
|
35
32
|
this_module = to_module(dbms)
|
@@ -40,10 +37,6 @@ module EDB
|
|
40
37
|
def to_module(dbms)
|
41
38
|
Object.const_get("::EDB::DBMS::#{dbms}")
|
42
39
|
end
|
43
|
-
|
44
|
-
def all_modules
|
45
|
-
constants.select { |c| const_get(c).is_a?(Module) }.map { |c| const_get(c) }
|
46
|
-
end
|
47
40
|
end
|
48
41
|
end
|
49
42
|
end
|
data/lib/edb/dumper.rb
CHANGED
@@ -36,25 +36,38 @@ module EDB
|
|
36
36
|
::EDB.opts[:DBMS].each do |dbms|
|
37
37
|
dbms_name = dbms[0]
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
unless EDB::DBMS.supports?(dbms_name)
|
40
|
+
module_not_supported(dbms_name)
|
41
|
+
next
|
42
|
+
end
|
43
|
+
|
44
|
+
dir_name = File.join(@dir_name, dbms_name.to_s)
|
45
|
+
FileUtils.mkdir(dir_name) unless Dir.exists?(dir_name)
|
42
46
|
|
43
|
-
|
47
|
+
files = EDB::DBMS.backup(dbms_name, dir_name)
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
if ::EDB.opts[:CRYPTOGRAPHY]
|
50
|
+
::EDB.opts[:CRYPTOGRAPHY].each do |cryptography|
|
51
|
+
algorithm = cryptography[0]
|
52
|
+
|
53
|
+
if ::EDB::Cryptography.supports?(algorithm)
|
54
|
+
files.each { |file| ::EDB::Cryptography.encrypt(algorithm, file) }
|
55
|
+
else
|
56
|
+
module_not_supported(algorithm)
|
48
57
|
end
|
49
58
|
end
|
59
|
+
end
|
50
60
|
|
51
|
-
|
52
|
-
|
53
|
-
|
61
|
+
if ::EDB.opts[:STORAGE]
|
62
|
+
::EDB.opts[:STORAGE].each do |storage|
|
63
|
+
service = storage[0]
|
64
|
+
|
65
|
+
if ::EDB::Cryptography.supports?(crypto)
|
66
|
+
files.each { |file| ::EDB::Storage.upload(service, file) }
|
67
|
+
else
|
68
|
+
module_not_supported(service)
|
54
69
|
end
|
55
70
|
end
|
56
|
-
else
|
57
|
-
::EDB::Logger.log(:error, "No support for #{dbms_name}.")
|
58
71
|
end
|
59
72
|
end
|
60
73
|
end
|
@@ -64,5 +77,9 @@ module EDB
|
|
64
77
|
@dir_name = PATTERN.call(Time.now)
|
65
78
|
Dir.mkdir(@dir_name) unless Dir.exists?(@dir_name)
|
66
79
|
end
|
80
|
+
|
81
|
+
def module_not_supported(module_name)
|
82
|
+
::EDB::Logger.log(:error, "No support for #{algorithm}.")
|
83
|
+
end
|
67
84
|
end
|
68
85
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright(C) 2015 Giovanni Capuano <webmaster@giovannicapuano.net>
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without modification, are
|
5
|
+
# permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
8
|
+
# conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# THIS SOFTWARE IS PROVIDED BY Giovanni Capuano ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
11
|
+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
12
|
+
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Giovanni Capuano OR
|
13
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
14
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
15
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
16
|
+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
17
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
18
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
19
|
+
#
|
20
|
+
# The views and conclusions contained in the software and documentation are those of the
|
21
|
+
# authors and should not be interpreted as representing official policies, either expressed
|
22
|
+
# or implied, of Giovanni Capuano.
|
23
|
+
#++
|
24
|
+
|
25
|
+
module EDB
|
26
|
+
module IsModuleSupported
|
27
|
+
def supports?(dbms)
|
28
|
+
begin
|
29
|
+
this_module = to_module(dbms)
|
30
|
+
all_modules.include?(this_module)
|
31
|
+
rescue NameError
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def all_modules
|
38
|
+
constants.select { |c| const_get(c).is_a?(Module) }.map { |c| const_get(c) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/edb/storage.rb
CHANGED
data/lib/edb/version.rb
CHANGED
data/lib/edb.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe EDB::Cryptography do
|
4
|
+
describe '#supports?' do
|
5
|
+
context 'given algorithm is supported' do
|
6
|
+
it 'returns true' do
|
7
|
+
expect(EDB::Cryptography.supports?('AES_256_CBC')).to be_truthy
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'given algorithm is not supported' do
|
12
|
+
it 'returns false' do
|
13
|
+
expect(EDB::Cryptography.supports?('LOL_WUT_128')).to be_falsy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/specs/dbms_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe EDB::Storage do
|
4
|
+
describe '#supports?' do
|
5
|
+
context 'given storage device is supported' do
|
6
|
+
it 'returns true' do
|
7
|
+
expect(EDB::Storage.supports?('S3')).to be_truthy
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'given storage device is not supported' do
|
12
|
+
it 'returns false' do
|
13
|
+
expect(EDB::Storage.supports?('CappellaAmbrosiana')).to be_falsy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'edb'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe EDB::Cryptography do
|
4
|
+
describe '#supports?' do
|
5
|
+
context 'given algorithm is supported' do
|
6
|
+
it 'returns true' do
|
7
|
+
expect(EDB::Cryptography.supports?('AES_256_CBC')).to be_truthy
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'given algorithm is not supported' do
|
12
|
+
it 'returns false' do
|
13
|
+
expect(EDB::Cryptography.supports?('LOL_WUT_128')).to be_falsy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.59.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
prerelease: false
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.3'
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
prerelease: false
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.10'
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
27
55
|
description: EDB aims to be a framework to make and manage backups of your database.
|
28
56
|
email: webmaster@giovannicapuano.net
|
29
57
|
executables:
|
@@ -47,11 +75,16 @@ files:
|
|
47
75
|
- lib/edb/dbms/postgresql.rb
|
48
76
|
- lib/edb/dumper.rb
|
49
77
|
- lib/edb/edb.rb
|
78
|
+
- lib/edb/is_module_supported.rb
|
50
79
|
- lib/edb/logger.rb
|
51
80
|
- lib/edb/storage.rb
|
52
81
|
- lib/edb/storage/filesystem.rb
|
53
82
|
- lib/edb/storage/s3.rb
|
54
83
|
- lib/edb/version.rb
|
84
|
+
- specs/cryptography_spec.rb
|
85
|
+
- specs/dbms_spec.rb
|
86
|
+
- specs/spec_helper.rb
|
87
|
+
- specs/storage_spec.rb
|
55
88
|
homepage: http://github.com/RoxasShadow/edb
|
56
89
|
licenses:
|
57
90
|
- BSD
|