Sha256: 0004a7ba57e888eeb46ad8c9f792f0ceb65124d9923cbc15db62601d3610271d
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
Contents
module Outback class DirectorySource < Source attr_reader :path def initialize(path) @path = path end def source_name path.gsub(/[^A-Za-z0-9\-_.]/, '_').gsub(/(\A_|_\z)/, '') end def excludes @excludes ||= [] end def exclude(*paths) excludes.concat(paths.map(&:to_s)).uniq! end def create_archives(backup_name, timestamp, tmpdir) source_dir = Pathname.new(path).realpath archive_name = Pathname.new(tmpdir).join("#{backup_name}_#{timestamp}_#{source_name}.tar.gz") exclude_list = Pathname.new(tmpdir).join('exclude_list.txt') File.open(exclude_list, 'w') { |f| f << excludes.join("\n") } commandline = "tar --create --file #{archive_name} --preserve-permissions --gzip --verbose --exclude-from #{exclude_list} #{source_dir}" Outback.debug "executing command: #{commandline}" result = `#{commandline}` Outback.debug result [TempArchive.new(archive_name, self)] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
outback-0.0.5 | lib/outback/directory_source.rb |
outback-0.0.4 | lib/outback/directory_source.rb |
outback-0.0.3 | lib/outback/directory_source.rb |