class Outback::DirectoryTarget
Attributes
path[R]
Public Class Methods
new(backup_name, path)
click to toggle source
Calls superclass method
# File lib/outback/directory_target.rb, line 6 def initialize(backup_name, path) super(backup_name) @path = Pathname.new(path) end
Public Instance Methods
put(archives)
click to toggle source
# File lib/outback/directory_target.rb, line 19 def put(archives) FileUtils.mkdir_p(path) unless path.directory? FileUtils.chmod directory_permissions || 0700, path size = 0 archives.each do |archive| basename = Pathname.new(archive.filename).basename if move logger.debug "moving #{archive.filename} to #{path}" FileUtils.mv archive.filename, path else logger.debug "copying #{archive.filename} to #{path}" FileUtils.cp_r archive.filename, path end archived_file = path.join(basename) logger.debug "setting permissions for #{archived_file}" FileUtils.chmod archive_permissions || 0600, archived_file if user && group logger.debug "setting owner #{user}, group #{group} for #{archived_file}" FileUtils.chown user, group, archived_file end size += archived_file.size end logger.info "#{move ? 'Moved' : 'Copied'} #{archives.size} archives (#{size} bytes) to #{self}" archives.size end
to_s()
click to toggle source
# File lib/outback/directory_target.rb, line 15 def to_s "directory:#{path}" end
valid?()
click to toggle source
# File lib/outback/directory_target.rb, line 11 def valid? (user and group) or (not user and not group) end
Private Instance Methods
list_all_archives()
click to toggle source
# File lib/outback/directory_target.rb, line 47 def list_all_archives path.files(Archive::NAME_PATTERN).map { |f| build_archive(f.to_s, f.size) } end
unlink_archive!(archive)
click to toggle source
# File lib/outback/directory_target.rb, line 51 def unlink_archive!(archive) archive.filename.unlink end