backup 4.0.3 → 4.0.4

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: b7e83c99df63edb4998a75a49d81a06b0d1039ca
4
- data.tar.gz: 5080aa4b34f9fc9104a1f312ad7418398b041148
3
+ metadata.gz: 5ca73fdee095965690119b7f88bd58f3275ca09e
4
+ data.tar.gz: a8d4446e87d9315ca051bb92a613c3608a777f5e
5
5
  SHA512:
6
- metadata.gz: 2e80a87dbf0a0d93cdb5ce0fb9a3f10c9b68b7d2ab2d49b5f30e8a77e3bf5763669ee7f0b853800283f3097c3c18fe0fc53f186dd0fbdb2bb5bacaf58b423c61
7
- data.tar.gz: 2dacfb012d43a5e19434427d76ddd0ddb3b03913eba7dce02ce3947397be1b7b3f663fb74bcd04e93ee5006c27c7487c2c5cdb61cff1e2200562e5e0bbe0a413
6
+ metadata.gz: 565291689a33745325adc776df783c1d314a50db30e5566bd0ac641a62df0f80788cc2c4c0eb64983a39fed23408047b7a9f6fd24a38d9cc2abfe63870f0d3fd
7
+ data.tar.gz: e1928778dc5c60155163f1a1994a74c3a0c07206c711b5f7ff5be58115906f25b6577878054a6a3c5d2e78b66eb1c36a7762a89bd0de60f71a903c99cb459c65
data/lib/backup.rb CHANGED
@@ -76,6 +76,7 @@ module Backup
76
76
  autoload :MongoDB, File.join(DATABASE_PATH, 'mongodb')
77
77
  autoload :Redis, File.join(DATABASE_PATH, 'redis')
78
78
  autoload :Riak, File.join(DATABASE_PATH, 'riak')
79
+ autoload :OpenLDAP, File.join(DATABASE_PATH, 'openldap')
79
80
  end
80
81
 
81
82
  ##
data/lib/backup/cli.rb CHANGED
@@ -142,6 +142,9 @@ module Backup
142
142
 
143
143
  rescue Exception => err
144
144
  Logger.error Error.wrap(err)
145
+ unless Helpers.is_backup_error? err
146
+ Logger.error err.backtrace.join("\n")
147
+ end
145
148
  # Logger configuration will be ignored
146
149
  # and messages will be output to the console only.
147
150
  Logger.abort!
@@ -219,6 +222,9 @@ module Backup
219
222
  Config.load(options)
220
223
  rescue Exception => err
221
224
  Logger.error Error.wrap(err)
225
+ unless Helpers.is_backup_error? err
226
+ Logger.error err.backtrace.join("\n")
227
+ end
222
228
  end
223
229
 
224
230
  if Logger.has_warnings? || Logger.has_errors?
@@ -357,6 +363,10 @@ module Backup
357
363
  exec(cmd)
358
364
  end
359
365
 
366
+ def is_backup_error?(error)
367
+ error.class.ancestors.include? Backup::Error
368
+ end
369
+
360
370
  end
361
371
  end
362
372
 
@@ -27,7 +27,7 @@ module Backup
27
27
  create_modules(
28
28
  DSL,
29
29
  [ # Databases
30
- ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis', 'Riak'],
30
+ ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis', 'Riak', 'OpenLDAP'],
31
31
  # Storages
32
32
  ['S3', 'CloudFiles', 'Ninefold', 'Dropbox', 'FTP',
33
33
  'SFTP', 'SCP', 'RSync', 'Local'],
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Database
5
+ class OpenLDAP < Base
6
+ class Error < Backup::Error; end
7
+
8
+ ##
9
+ # Name of the ldap backup
10
+ attr_accessor :name
11
+
12
+ ##
13
+ # run slapcat under sudo if needed
14
+ # make sure to set SUID on a file, to let you run the file with permissions of file owner
15
+ # eg. sudo chmod u+s /usr/sbin/slapcat
16
+ attr_accessor :use_sudo
17
+
18
+ ##
19
+ # Stores the location of the slapd.conf or slapcat confdir
20
+ attr_accessor :slapcat_conf
21
+
22
+ ##
23
+ # Additional slapcat options
24
+ attr_accessor :slapcat_args
25
+
26
+ ##
27
+ # Path to slapcat utility (optional)
28
+ attr_accessor :slapcat_utility
29
+
30
+ ##
31
+ # Takes the name of the archive and the configuration block
32
+ def initialize(model, database_id = nil, &block)
33
+ super
34
+ instance_eval(&block) if block_given?
35
+
36
+ @name ||= 'ldap_backup'
37
+ @use_sudo ||= false
38
+ @slapcat_args ||= Array.new
39
+ @slapcat_utility ||= utility(:slapcat)
40
+ @slapcat_conf ||= '/etc/ldap/slapd.d'
41
+ end
42
+
43
+ ##
44
+ # Performs the slapcat command and outputs the
45
+ # data to the specified path based on the 'trigger'
46
+ def perform!
47
+ super
48
+
49
+ pipeline = Pipeline.new
50
+ dump_ext = 'ldif'
51
+
52
+ pipeline << slapcat
53
+ if @model.compressor
54
+ @model.compressor.compress_with do |command, ext|
55
+ pipeline << command
56
+ dump_ext << ext
57
+ end
58
+ end
59
+
60
+ pipeline << "#{ utility(:cat) } > " +
61
+ "'#{ File.join(dump_path, dump_filename) }.#{ dump_ext }'"
62
+
63
+ pipeline.run
64
+ if pipeline.success?
65
+ log!(:finished)
66
+ else
67
+ raise Error, "Dump Failed!\n" + pipeline.error_messages
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ ##
74
+ # Builds the full slapcat string based on all attributes
75
+ def slapcat
76
+ command = "#{ slapcat_utility } #{ slapcat_conf_option } #{ slapcat_conf } #{ user_options }"
77
+ command.prepend("sudo ") if use_sudo
78
+ command
79
+ end
80
+
81
+ ##
82
+ # Uses different slapcat switch depending on confdir or conffile set
83
+ def slapcat_conf_option
84
+ @slapcat_conf.include?(".d") ? "-F" : "-f"
85
+ end
86
+
87
+ ##
88
+ # Builds a compatible string for the additional options
89
+ # specified by the user
90
+ def user_options
91
+ slapcat_args.join(' ')
92
+ end
93
+ end
94
+ end
95
+ end
@@ -22,6 +22,14 @@ module Backup
22
22
  # The username to display along with the notification
23
23
  attr_accessor :username
24
24
 
25
+ ##
26
+ # The emoji icon to display along with the notification
27
+ #
28
+ # See http://www.emoji-cheat-sheet.com for a list of icons.
29
+ #
30
+ # Default: :floppy_disk:
31
+ attr_accessor :icon_emoji
32
+
25
33
  ##
26
34
  # Array of statuses for which the log file should be attached.
27
35
  #
@@ -34,6 +42,7 @@ module Backup
34
42
  instance_eval(&block) if block_given?
35
43
 
36
44
  @send_log_on ||= [:warning, :failure]
45
+ @icon_emoji ||= ':floppy_disk:'
37
46
  end
38
47
 
39
48
  private
@@ -64,7 +73,7 @@ module Backup
64
73
  message = "#{ tag } #{ model.label } (#{ model.trigger })"
65
74
 
66
75
  data = { :text => message }
67
- [:channel, :username].each do |param|
76
+ [:channel, :username, :icon_emoji].each do |param|
68
77
  val = send(param)
69
78
  data.merge!(param => val) if val
70
79
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '4.0.3'
4
+ VERSION = '4.0.4'
5
5
  end
@@ -0,0 +1,24 @@
1
+ ##
2
+ # OpenLDAP [Database]
3
+ #
4
+ database OpenLDAP do |db|
5
+ # Name of the ldap backup
6
+ db.name = "my_database_name"
7
+
8
+ # Additional "slapcat" options
9
+ # defaults to an empty list of options
10
+ # db.slapcat_args = []
11
+
12
+ # run slapcat under sudo if needed
13
+ # defaults to "false"
14
+ # db.use_sudo = true
15
+
16
+ # Stores the location of the slapd.conf,
17
+ # defaults to "/etc/ldap/slapd.d" confdir
18
+ # you can use also conf file instead of directory
19
+ # db.slapcat_conf = /path/to/slapd.conf
20
+
21
+ # Optional: Use to set the location of slapcat utility
22
+ # if it cannot be found by name in your $PATH
23
+ # db.slapcat_utility = "/opt/local/bin/slapcat"
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -575,6 +575,7 @@ files:
575
575
  - lib/backup/database/base.rb
576
576
  - lib/backup/database/mongodb.rb
577
577
  - lib/backup/database/mysql.rb
578
+ - lib/backup/database/openldap.rb
578
579
  - lib/backup/database/postgresql.rb
579
580
  - lib/backup/database/redis.rb
580
581
  - lib/backup/database/riak.rb
@@ -634,6 +635,7 @@ files:
634
635
  - templates/cli/config
635
636
  - templates/cli/databases/mongodb
636
637
  - templates/cli/databases/mysql
638
+ - templates/cli/databases/openldap
637
639
  - templates/cli/databases/postgresql
638
640
  - templates/cli/databases/redis
639
641
  - templates/cli/databases/riak