class BackupFoundation::Item::Base
Public Class Methods
new(options, tmpdir, encryption_key=nil)
click to toggle source
# File lib/backup_foundation/item/base.rb, line 4 def initialize(options, tmpdir, encryption_key=nil) @options = options @encryption_key = encryption_key @tmpdir = tmpdir end
Public Instance Methods
decrypt_if_needed_and_restore(command, infile_path)
click to toggle source
# File lib/backup_foundation/item/base.rb, line 29 def decrypt_if_needed_and_restore(command, infile_path) if @encryption_key IO.pipe do |rp, wp| wp.puts @encryption_key system "cat #{infile_path} | gpg --yes --batch --passphrase-fd=3 -q -r -d | gunzip -c | #{command}", 3 => rp end else `gunzip -c #{infile_path} | #{command}` end end
dump_and_encrypt_if_needed(command)
click to toggle source
# File lib/backup_foundation/item/base.rb, line 18 def dump_and_encrypt_if_needed(command) if @encryption_key IO.pipe do |rp, wp| wp.puts @encryption_key system output_to_file("#{command} | gzip -cf | gpg --yes --batch --passphrase-fd=3 -q -r -e -c"), 3 => rp end else `#{output_to_file("#{command} | gzip -cf")}` end end
outfile_path()
click to toggle source
# File lib/backup_foundation/item/base.rb, line 10 def outfile_path "#{@tmpdir}/#{File.basename(@options[:database] || @options[:name])}.gz#{'.gpg' if @encryption_key}" end
output_to_file(command)
click to toggle source
# File lib/backup_foundation/item/base.rb, line 14 def output_to_file(command) "#{command} > #{outfile_path}" end