class Backup::Database::OpenLDAP
Attributes
name[RW]
Name of the ldap backup
slapcat_args[RW]
Additional slapcat options
slapcat_conf[RW]
Stores the location of the slapd.conf or slapcat confdir
slapcat_utility[RW]
Path to slapcat utility (optional)
use_sudo[RW]
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
Public Class Methods
new(model, database_id = nil, &block)
click to toggle source
Takes the name of the archive and the configuration block
Calls superclass method
Backup::Database::Base::new
# 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
Public Instance Methods
perform!()
click to toggle source
Performs the slapcat command and outputs the data to the specified path based on the ‘trigger’
Calls superclass method
Backup::Database::Base#perform!
# 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.error_messages end end
Private Instance Methods
slapcat()
click to toggle source
Builds the full slapcat string based on all attributes
# File lib/backup/database/openldap.rb, line 73 def slapcat command = "#{slapcat_utility} #{slapcat_conf_option} #{slapcat_conf} #{user_options}" command.prepend("sudo ") if use_sudo command end
slapcat_conf_option()
click to toggle source
Uses different slapcat switch depending on confdir or conffile set
# File lib/backup/database/openldap.rb, line 81 def slapcat_conf_option @slapcat_conf.include?(".d") ? "-F" : "-f" end
user_options()
click to toggle source
Builds a compatible string for the additional options specified by the user
# File lib/backup/database/openldap.rb, line 88 def user_options slapcat_args.join(" ") end