Sha256: 775d75e47adeeac460b1f7e196464a9caed24cdcb707d80695e19d1f8c99a2c2

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

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
      
      set_backup_size(tar_gz_path)
    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

7 entries across 7 versions & 1 rubygems

Version Path
keepitsafe-0.2.6 lib/plugins/tar.rb
keepitsafe-0.2.5 lib/plugins/tar.rb
keepitsafe-0.2.4 lib/plugins/tar.rb
keepitsafe-0.2.3 lib/plugins/tar.rb
keepitsafe-0.2.2 lib/plugins/tar.rb
keepitsafe-0.2.1 lib/plugins/tar.rb
keepitsafe-0.2.0 lib/plugins/tar.rb