Sha256: 942cdced4a24e18187a0f61c837fe329ac9497ef55515c60e6d9b7465787a1ad

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

module Backup
  module Database
    class SQLite < Base
      class Error < Backup::Error; end

      ##
      # Path to the sqlite3 file
      attr_accessor :path

      ##
      # Path to sqlite utility (optional)
      attr_accessor :sqlitedump_utility

      ##
      # Creates a new instance of the SQLite adapter object
      def initialize(model, database_id = nil, &block)
        super
        instance_eval(&block) if block_given?

        @sqlitedump_utility ||= utility(:sqlitedump)
      end

      ##
      # Performs the sqlitedump command and outputs the
      # data to the specified path based on the 'trigger'
      def perform!
        super

        dump = "echo '.dump' | #{sqlitedump_utility} #{path}"

        pipeline = Pipeline.new
        dump_ext = "sql"

        pipeline << dump
        if model.compressor
          model.compressor.compress_with do |command, ext|
            pipeline << command
            dump_ext << ext
          end
        end

        pipeline << "cat > '#{File.join(dump_path, dump_filename)}.#{dump_ext}'"

        pipeline.run

        if pipeline.success?
          log!(:finished)
        else
          raise Error,
            "#{database_name} Dump Failed!\n" + pipeline.error_messages
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
backup-5.0.0.beta.3 lib/backup/database/sqlite.rb
backedup-5.0.0.beta.5 lib/backup/database/sqlite.rb
backedup-5.0.0.beta.4 lib/backup/database/sqlite.rb
backedup-5.0.0.beta.3 lib/backup/database/sqlite.rb
ext_backup-5.0.0.beta.2.1 lib/backup/database/sqlite.rb
ext_backup-5.0.0.beta.2.ext.0.1.2 lib/backup/database/sqlite.rb
ext_backup-5.0.0.beta.2.ext.0.1.1 lib/backup/database/sqlite.rb
ext_backup-5.0.0.beta.2.ext.0.1.0 lib/backup/database/sqlite.rb
backup-5.0.0.beta.2 lib/backup/database/sqlite.rb
backup-5.0.0.beta.1 lib/backup/database/sqlite.rb
backup-bouchard-4.4.4 lib/backup/database/sqlite.rb
backup-bouchard-4.4.2 lib/backup/database/sqlite.rb
backup-bouchard-4.4.1 lib/backup/database/sqlite.rb