Sha256: 80316a44d1275780b62df1259fed042dce43890813d8094b8d96aec10dd4fae1

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

module Backup
  module Adapter
    class Sqlite3 < Backup::Base
    
      def initialize(options = {})
        super(default_options.merge(options))
        setup_paths("db/#{self.class.name.downcase.gsub('::','-')}", :gz)
      end
    
      # Initialize the process
      # Executing multiple processes
      #
      # - 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
          compress
          encrypt
          transfer
          record
        ensure
          remove_temp_files
        end
      end
    
      private
      
        # Compresses the SQLite3file and stores the compressed version inside the tmp/backups folder.
        def compress
          %x{ gzip -cv #{File.join(options[:path], options[:file])} --best > #{File.join(options[:backup_path], options[:backup_file])} }
        end
      
        # Set default options
        def default_options
          { :path => "#{RAILS_ROOT}/db",
            :file => "production.sqlite3" }
        end
    
    end  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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