Sha256: f484c6cdbafc8b44606f927e3d401800e8c797d3390afd94675401a534de6993

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module Backup
  module Adapter
    class Assets < Backup::Base
    
      def initialize(options = {})
        super(default_options.merge(options))
        setup_paths("assets/#{self.class.name.downcase.gsub('::','-')}", 'tar.gz')
      end
    
      # Initialize the process
      # Executing multiple processes
      # 
      # - Archive
      #   Archives the specified folder to a .tar
      # - Compress
      #   Compresses the .tar file using Gzip
      # - Encrypt
      #   Encrypts the backup file
      # - Transfer
      #   Initializes the transfer to either S3 or using SSH
      # - Record
      #   Records the Backup Data to the Backup SQLite3 database
      # - Remove Temp Files
      #   Removes temporary files after the process is complete
      def run
        begin
          archive
          compress
          encrypt
          transfer
          record
        ensure
          remove_temp_files
        end
      end
    
      private
      
        # Archives the assets into a .tar file and stores it
        # inside the "Backup Path"
        def archive
          %x{ tar -cf #{File.join(options[:backup_path], options[:backup_file])} #{options[:path]} }
        end
      
        # Compresses the .tar file to .tar.gz and removes the old .tar file
        def compress
          %x{ gzip --best #{File.join(options[:backup_path], options[:backup_file])} }
        end
      
        # Set default options
        def default_options
          { :path => "#{RAILS_ROOT}/public/assets", :file => "assets" }
        end
    
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backup-1.3.4 lib/backup/adapter/assets.rb
backup-1.3.3 lib/backup/adapter/assets.rb