simple_backup 0.3.0 → 0.4.0

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: db18d1aeca0f0b1e397e8599de6ed70474fd49e1
4
- data.tar.gz: 9e70279a4648074f77da59a0f070a869ce8c555d
3
+ metadata.gz: 0469f56e22f8ab0f509e8a51eb8ffdfd820ac023
4
+ data.tar.gz: 17b0d6e3a9c824e2e49567dda5d9eeacc2f76044
5
5
  SHA512:
6
- metadata.gz: d94e122a1bfab65a376e29087564568917c939149cec9d52c37d5905dd683687b033b1132fb28bcf6cf373da9f0fc3cb6492fd8cc30fe1c09bb2d38ef3412421
7
- data.tar.gz: 00bb1b44ad48000765a9aa84817cc451772886beb03dc41e07a7503cbcf3d2e4d1293844de049caa6987d5d11a0221f57534453cafa9904ff4356d38eae1c54b
6
+ metadata.gz: 89f78bb4979170c15b9c2467e7cadb1d70889b67ec46786e1aff3732a417e59aac3af0b5c03cd311be76ae346d5a69a5e3f41064a61ee805040ce2f097daeb5f
7
+ data.tar.gz: 6c28e913f0964292ec9013ca023391da1880213026f5bc0bce1583b1443b742aafdd60ee757aa4f99ea24f1b672d7e45033697f70cbce6ffa1d2457f5805332d
data/README.md CHANGED
@@ -1,18 +1,20 @@
1
1
  # simple_backup
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/simple_backup.svg)](http://badge.fury.io/rb/simple_backup)
4
- ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)
4
+ [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tmaczukin/simple_backup/blob/development/LICENSE)
5
5
 
6
6
  Backup tool with simple DSL for configuration. Tool is under heavy
7
7
  development and its API should be treat as unstable.
8
8
 
9
9
  ## TODO
10
10
 
11
- - [ ] Refactorization
12
- - [ ] Few backends for backup store (file, s3, ftp)
13
- - [ ] Filters mechanism (e.g. PGP encryption)
14
- - [ ] Tests
15
- - [ ] Docummentation and examples
11
+ - [x] Change architecture and refactorize
12
+ - [x] Add sources mechanism
13
+ - [x] Add backends mechanism (with 'local' backend implementation)
14
+ - [ ] Add more backends (e.g. s3, ftp)
15
+ - [ ] Add filters mechanism (e.g. PGP encryption)
16
+ - [ ] Add tests
17
+ - [ ] Add docummentation and examples
16
18
 
17
19
  ## License
18
20
 
data/backup_example.rb CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'simple_backup'
7
7
 
8
- SimpleBackup.run do
8
+ SimpleBackup.define do
9
9
  log_level :debug
10
10
 
11
11
  high_usage_treshold 0.9
@@ -16,15 +16,15 @@ SimpleBackup.run do
16
16
  default_keep_last 9
17
17
 
18
18
  sources do
19
- dir 'app-1', '/home/app/app-1', type: :capistrano, backends: 'backup'
20
- dir 'app-2', '/home/app/app-2', backends: :none
21
- dir 'none', '/none'
19
+ dir 'app-1', path: '/home/app/app-1', type: :capistrano, backends: 'backup'
20
+ dir 'app-2', path: '/home/app/app-2', backends: :none
21
+ dir 'none', path: '/none'
22
22
 
23
- file 'hosts', '/etc/hosts'
23
+ file 'hosts', path: '/etc/hosts'
24
24
 
25
- mysql 'test1', 'test1'
26
- mysql 'test2', 'test2'
27
- mysql 'test3', 'test3', exclude_tables: ['t_test1']
25
+ mysql 'test1'
26
+ mysql 'test2'
27
+ mysql 'test3', exclude_tables: ['t_test1']
28
28
  end
29
29
 
30
30
  backends do
data/lib/simple_backup.rb CHANGED
@@ -15,7 +15,7 @@ module SimpleBackup
15
15
  @@status
16
16
  end
17
17
 
18
- def self.run(&block)
18
+ def self.define(&block)
19
19
  @@logger.scope_start :info, "Backup #{TIMESTAMP} started"
20
20
 
21
21
  engine = Engine::Engine.new
@@ -7,7 +7,7 @@ module SimpleBackup
7
7
  class Abstract
8
8
  @@logger = Utils::Logger.instance
9
9
 
10
- def configure(*args)
10
+ def configure(options = {})
11
11
  raise NotImplementedError
12
12
  end
13
13
 
@@ -5,10 +5,11 @@ module SimpleBackup
5
5
  @strategy = :bare
6
6
  end
7
7
 
8
- def configure(path, options = {})
9
- @path = path
8
+ def configure(options = {})
9
+ raise "Must provide :path parameter" unless options[:path]
10
+ @path = options[:path]
10
11
 
11
- raise "#{path} is a file - use File source instead of Dir" unless !::File.exist?(path) or ::File.directory?(path)
12
+ raise "#{@path} is a file - use File source instead of Dir" unless !::File.exist?(@path) or ::File.directory?(@path)
12
13
  @strategy = options[:strategy] if options[:strategy]
13
14
  end
14
15
 
@@ -1,10 +1,11 @@
1
1
  module SimpleBackup
2
2
  module Source
3
3
  class File < Abstract
4
- def configure(path, options = {})
5
- @path = path
4
+ def configure(options = {})
5
+ raise "Must provide :path parameter" unless options[:path]
6
+ @path = options[:path]
6
7
 
7
- raise "#{path} is a directory - use Dir source instead of File" unless !::File.exist?(path) or ::File.file?(path)
8
+ raise "#{@path} is a directory - use Dir source instead of File" unless !::File.exist?(@path) or ::File.file?(@path)
8
9
  end
9
10
 
10
11
  private
@@ -3,8 +3,9 @@ module SimpleBackup
3
3
  class Mysql < Abstract
4
4
  @@mysql = Utils::MySQL.instance
5
5
 
6
- def configure(db, options = {})
7
- @db = db
6
+ def configure(options = {})
7
+ @db = @name unless options[:db]
8
+ @db = options[:db] if options[:db]
8
9
 
9
10
  @exclude_tables = options[:exclude_tables] if options[:exclude_tables]
10
11
  end
@@ -42,7 +42,6 @@ module SimpleBackup
42
42
  return nil if source.nil?
43
43
 
44
44
  name = args.shift
45
- identifier = args.shift
46
45
  options = args.shift
47
46
  options ||= {}
48
47
 
@@ -55,7 +54,7 @@ module SimpleBackup
55
54
  source.backends = options[:backends] if options[:backends]
56
55
  source.name = name
57
56
 
58
- source.configure(identifier, options)
57
+ source.configure(options)
59
58
 
60
59
  @@logger.info "Created source for: #{source.desc.strip}"
61
60
 
@@ -75,8 +75,8 @@ module SimpleBackup
75
75
 
76
76
  scope_prefix = '..' * @scope
77
77
  message = "%s %7s: %s%s" % [Time.new.strftime(TIME_FORMAT), level.to_s.upcase, scope_prefix, message]
78
- @buffer << message
79
78
 
79
+ @buffer << message if should_write
80
80
  puts message.colorize(color: color) if should_write
81
81
  end
82
82
 
@@ -100,7 +100,7 @@ Have a nice day,
100
100
  SimpleBackup
101
101
 
102
102
  --
103
- Mail was send automatically
103
+ Mail was sent automatically
104
104
  Do not respond!
105
105
  MAIL
106
106
 
@@ -1,7 +1,7 @@
1
1
  module SimpleBackup
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 3
4
+ MINOR = 4
5
5
  PATCH = 0
6
6
  PRE_RELEASE = nil
7
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Maczukin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-18 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.5
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Backup tool with simple DSL for configuration