Class: Backup::Database::OpenLDAP
- Defined in:
- lib/backup/database/openldap.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#name ⇒ Object
Name of the ldap backup.
-
#slapcat_args ⇒ Object
Additional slapcat options.
-
#slapcat_conf ⇒ Object
Stores the location of the slapd.conf or slapcat confdir.
-
#slapcat_utility ⇒ Object
Path to slapcat utility (optional).
-
#use_sudo ⇒ Object
run slapcat under sudo if needed make sure to set SUID on a file, to let you run the file with permissions of file owner eg.
Attributes inherited from Base
#database_id, #dump_path, #model
Instance Method Summary collapse
-
#initialize(model, database_id = nil, &block) ⇒ OpenLDAP
constructor
Takes the name of the archive and the configuration block.
-
#perform! ⇒ Object
Performs the slapcat command and outputs the data to the specified path based on the ‘trigger’.
Methods included from Config::Helpers
Constructor Details
#initialize(model, database_id = nil, &block) ⇒ OpenLDAP
Takes the name of the archive and the configuration block
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/backup/database/openldap.rb', line 30 def initialize(model, database_id = nil, &block) super instance_eval(&block) if block_given? @name ||= "ldap_backup" @use_sudo ||= false @slapcat_args ||= [] @slapcat_utility ||= utility(:slapcat) @slapcat_conf ||= "/etc/ldap/slapd.d" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#name ⇒ Object
Name of the ldap backup
8 9 10 |
# File 'lib/backup/database/openldap.rb', line 8 def name @name end |
#slapcat_args ⇒ Object
Additional slapcat options
22 23 24 |
# File 'lib/backup/database/openldap.rb', line 22 def slapcat_args @slapcat_args end |
#slapcat_conf ⇒ Object
Stores the location of the slapd.conf or slapcat confdir
18 19 20 |
# File 'lib/backup/database/openldap.rb', line 18 def slapcat_conf @slapcat_conf end |
#slapcat_utility ⇒ Object
Path to slapcat utility (optional)
26 27 28 |
# File 'lib/backup/database/openldap.rb', line 26 def slapcat_utility @slapcat_utility end |
#use_sudo ⇒ Object
run slapcat under sudo if needed make sure to set SUID on a file, to let you run the file with permissions of file owner eg. sudo chmod u+s /usr/sbin/slapcat
14 15 16 |
# File 'lib/backup/database/openldap.rb', line 14 def use_sudo @use_sudo end |
Instance Method Details
#perform! ⇒ Object
Performs the slapcat command and outputs the data to the specified path based on the ‘trigger’
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/backup/database/openldap.rb', line 44 def perform! super pipeline = Pipeline.new dump_ext = "ldif" pipeline << slapcat if @model.compressor @model.compressor.compress_with do |command, ext| pipeline << command dump_ext << ext end end pipeline << "#{utility(:cat)} > " \ "'#{File.join(dump_path, dump_filename)}.#{dump_ext}'" pipeline.run if pipeline.success? log!(:finished) else raise Error, "Dump Failed!\n" + pipeline. end end |