Sha256: 20183c96f994bf6230d545b36dd5ee2ce08d5bf278b407fa802620d1d3dc9c96
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
module Astrails module Safe class Local < Sink protected def active? # S3 can't upload from pipe. it needs to know file size, so we must pass through :local # will change once we add SSH/FTP sink true end def path @path ||= File.expand_path(expand(config[:local, :path] || raise(RuntimeError, "missing :local/:path"))) end def save puts "command: #{@backup.command}" if verbose? # FIXME: probably need to change this to smth like @backup.finalize! @backup.path = full_path # need to do it outside DRY_RUN so that it will be avialable for S3 DRY_RUN unless dry_run? FileUtils.mkdir_p(path) unless File.directory?(path) benchmark = Benchmark.realtime do system "#{@backup.command}>#{@backup.path}" end puts("command took " + sprintf("%.2f", benchmark) + " second(s).") if verbose? end end def cleanup return unless keep = config[:keep, :local] puts "listing files #{base}" if verbose? # TODO: cleanup ALL zero-length files files = Dir["#{base}*"] . select{|f| File.file?(f) && File.size(f) > 0} . sort cleanup_with_limit(files, keep) do |f| puts "removing local file #{f}" if dry_run? || verbose? File.unlink(f) unless dry_run? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
akupchanko-astrails-safe-0.3.1 | lib/astrails/safe/local.rb |