Sha256: da99d0fb37896ea491e6021db7ff81ac2e196547074c764ce682c210d094c1cc

Contents?: true

Size: 1002 Bytes

Versions: 5

Compression:

Stored size: 1002 Bytes

Contents

module BackupPlugins
  module Tar
    
    def tar_path
      "#{backup_target_dir[0..-2]}.tar"
    end
    
    def tar_gz_path
      "#{backup_target_dir[0..-2]}.tar.gz"
    end
    
    def tar options = {:keep_files => false}
      puts "\n\tTaring files"
      puts run_cmd "cd #{backup_dir_path}; tar -cf #{tar_path} #{backup_dir_name}"
      unless options[:keep_files]
        puts "\n\tRemoving backup dir" 
        puts run_cmd "rm -rf #{backup_target_dir}" 
      end
    end
    
    def tar_gz options = {:keep_files => false}
      puts "\n\tTaring and gziping files\n\n"
      puts run_cmd "cd #{backup_dir_path}; tar -czf #{tar_gz_path} #{backup_dir_name}"
      
      unless options[:keep_files]
        puts "\n\tRemoving backup dir" 
        puts run_cmd "rm -rf #{backup_target_dir}" 
      end
    end
    
    private 
    
    def backup_dir_path
      File.dirname(backup_target_dir)
    end
    
    def backup_dir_name
      File.basename(backup_target_dir)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
keepitsafe-0.1.10 lib/plugins/tar.rb
keepitsafe-0.1.7 lib/plugins/tar.rb
keepitsafe-0.1.5 lib/plugins/tar.rb
keepitsafe-0.1.4 lib/plugins/tar.rb
keepitsafe-0.1.3 lib/plugins/tar.rb