edb 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +10 -7
- data/example/edb.yml +14 -4
- data/lib/edb/dbms/mysql.rb +44 -0
- data/lib/edb/dumper.rb +4 -1
- data/lib/edb/storage/filesystem.rb +46 -0
- data/lib/edb/storage/s3.rb +1 -1
- data/lib/edb/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f580ad47ecf9f08fcaea47a751ee8fa4e713cfc0
|
4
|
+
data.tar.gz: 8b61eba1dd93dcf190bbda91be07bf17b57fe1f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b02a60eb7d3dc733544c70c4b687243df8fe7bb752b208254bfba4207748bdbc69abc7f9d7a4c9a092680bc20bdd59cbc45383a57ee326bdede89f79599f073e
|
7
|
+
data.tar.gz: 8cca6ca8141d811d340c2639406785ea86813f65efd11b2c4a6cf214a9d480498689bf1bda6f7395a4d83d40f89bfc579af481c6ba413caf2b7bc5173e65a5bd
|
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# Backup, encrypt and manage your database
|
2
2
|
|
3
|
-
*EDB*
|
4
|
-
It is composed by three macro areas that reflect themself inside
|
5
|
-
The first one
|
6
|
-
|
7
|
-
At the moment, we have just one module for each area: *PostgreSQL*, *AWS S3* and *AES-256-CBC*, but adding more modules require nothing but a new file inside the proper folder.
|
3
|
+
*EDB* is a framework to make and manage backups of your database.
|
4
|
+
It is composed by three macro areas that reflect themself inside `edb.yml` and are *DBMS*, *CRYPTOGRAPHY* and *STORAGE*.
|
5
|
+
The first one deals with the actual backup process of your database. The second one will eventually encrypt the backup copies you made and the last one will copy them somewhere (S3 bucket, your local filesystem, etc.).
|
8
6
|
|
9
7
|
## Install
|
10
8
|
`$ gem install edb`
|
11
9
|
|
12
10
|
## Run
|
13
|
-
Setup `example/edb.yml` (remember also to change the `
|
11
|
+
Setup and customize `example/edb.yml` (remember also to change the `secret`) and then:
|
14
12
|
|
15
|
-
`$ edb example/edb.yml`
|
13
|
+
`$ edb example/edb.yml`
|
16
14
|
|
17
15
|
Consider also to add *EDB* to your cronjobs.
|
16
|
+
|
17
|
+
## Available modules
|
18
|
+
- *Cryptography*: `AES_256_CBC`
|
19
|
+
- *DBMS*: `PostgreSQL`, `MySQL`
|
20
|
+
- *Storage*: `S3`, `Filesystem`
|
data/example/edb.yml
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
---
|
2
2
|
:DBMS:
|
3
3
|
:PostgreSQL:
|
4
|
-
:binpath:
|
5
|
-
:username:
|
6
|
-
:password:
|
7
|
-
:database:
|
4
|
+
:binpath: /Applications/Postgres.app/Contents/Versions/9.3/bin
|
5
|
+
:username: username
|
6
|
+
:password: password
|
7
|
+
:database: sample_database
|
8
8
|
:host: localhost
|
9
9
|
:port: 5432
|
10
10
|
|
11
|
+
:MySQL:
|
12
|
+
:binpath: /Applications/MAMP/Library/bin
|
13
|
+
:username: username
|
14
|
+
:password: password
|
15
|
+
:database: sample_database
|
16
|
+
:host: localhost
|
17
|
+
|
11
18
|
:CRYPTOGRAPHY:
|
12
19
|
:AES_256_CBC:
|
13
20
|
:secret: 0279x62O116Hn50016AGJE6D5De4gn4r
|
@@ -20,3 +27,6 @@
|
|
20
27
|
:bucket:
|
21
28
|
:main: backups
|
22
29
|
:folder: sample-project
|
30
|
+
|
31
|
+
:Filesystem:
|
32
|
+
:path: ~/Downloads
|
@@ -0,0 +1,44 @@
|
|
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 DBMS
|
27
|
+
module MySQL
|
28
|
+
class << self
|
29
|
+
def backup(dir_name)
|
30
|
+
db = ::EDB.opts[:DBMS][:MySQL]
|
31
|
+
files = {
|
32
|
+
dump: File.join(dir_name, "#{db[:database]}.sql")
|
33
|
+
}
|
34
|
+
|
35
|
+
::EDB::Logger.log(:info, "Dumping #{db[:database]}...")
|
36
|
+
mysqldump = db[:binpath] && !db[:binpath].empty? ? File.join(db[:binpath], 'mysqldump') : 'mysqldump'
|
37
|
+
system "#{mysqldump} -u #{db[:username]} --password=#{db[:password]} --default-character-set=utf8 #{db[:database]} > #{files[:dump]}"
|
38
|
+
|
39
|
+
files.values
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/edb/dumper.rb
CHANGED
@@ -37,7 +37,10 @@ module EDB
|
|
37
37
|
dbms_name = dbms[0]
|
38
38
|
|
39
39
|
if EDB::DBMS.supports?(dbms_name)
|
40
|
-
|
40
|
+
dir_name = File.join(@dir_name, dbms_name.to_s)
|
41
|
+
FileUtils.mkdir(dir_name) unless Dir.exists?(dir_name)
|
42
|
+
|
43
|
+
files = EDB::DBMS.backup(dbms_name, dir_name)
|
41
44
|
|
42
45
|
if ::EDB.opts[:CRYPTOGRAPHY]
|
43
46
|
::EDB.opts[:CRYPTOGRAPHY].each do |method|
|
@@ -0,0 +1,46 @@
|
|
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
|
+
require 'fileutils'
|
25
|
+
|
26
|
+
module EDB
|
27
|
+
module Storage
|
28
|
+
module Filesystem
|
29
|
+
class << self
|
30
|
+
def upload(source)
|
31
|
+
filesystem = ::EDB.opts[:STORAGE][:Filesystem]
|
32
|
+
|
33
|
+
path = File.expand_path(filesystem[:path])
|
34
|
+
folder = source.split('/')[0..-2].join('/')
|
35
|
+
path = File.join(path, folder)
|
36
|
+
::EDB::Logger.log(:info, "Copying #{source} to #{path}...")
|
37
|
+
|
38
|
+
FileUtils.mkdir_p(path) unless Dir.exists?(path)
|
39
|
+
|
40
|
+
source = File.join('./', source)
|
41
|
+
FileUtils.cp_r(source, path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/edb/storage/s3.rb
CHANGED
data/lib/edb/version.rb
CHANGED
metadata
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
15
|
+
prerelease: false
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - '='
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: 1.59.1
|
20
21
|
type: :runtime
|
21
|
-
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
@@ -31,6 +31,7 @@ executables:
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".gitignore"
|
34
35
|
- Gemfile
|
35
36
|
- Gemfile.lock
|
36
37
|
- README.md
|
@@ -42,11 +43,13 @@ files:
|
|
42
43
|
- lib/edb/cryptography.rb
|
43
44
|
- lib/edb/cryptography/aes_256_cbc.rb
|
44
45
|
- lib/edb/dbms.rb
|
46
|
+
- lib/edb/dbms/mysql.rb
|
45
47
|
- lib/edb/dbms/postgresql.rb
|
46
48
|
- lib/edb/dumper.rb
|
47
49
|
- lib/edb/edb.rb
|
48
50
|
- lib/edb/logger.rb
|
49
51
|
- lib/edb/storage.rb
|
52
|
+
- lib/edb/storage/filesystem.rb
|
50
53
|
- lib/edb/storage/s3.rb
|
51
54
|
- lib/edb/version.rb
|
52
55
|
homepage: http://github.com/RoxasShadow/edb
|
@@ -69,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
72
|
version: '0'
|
70
73
|
requirements: []
|
71
74
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.4.
|
75
|
+
rubygems_version: 2.4.8
|
73
76
|
signing_key:
|
74
77
|
specification_version: 4
|
75
78
|
summary: A framework to make and manage backups of your database.
|