Sha256: bdae740fb77dac31e07f01b66180e905354451c48d60447d103ebebd9dcd346e

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require_relative 'base_driver'

module Ariranha
  module Drivers
    class Postgresql < BaseDriver
      def database
        pgsql_database
      end

      private

      attr_reader :pgsql_database, :pgsql_host, :pgsql_user, :pgsql_password

      def config_driver
        config.each do |k, v|
          instance_variable_set("@pgsql_#{k}".to_sym, v)
        end
      end

      def backup_cmd
        envs = {}
        envs['PGPASSWORD'] = pgsql_password if pgsql_password
        cmd = 'pg_dump -Fc --no-acl --no-owner '
        cmd += "--host=#{pgsql_host} " if pgsql_host
        cmd += "--username=#{pgsql_user} " if pgsql_user
        cmd += "#{pgsql_database} > /tmp/#{filename}"
        [envs, cmd]
      end

      def filename
        "#{pgsql_database}-#{timestamp}.dump"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ariranha-0.0.3 lib/ariranha/drivers/postgresql.rb
ariranha-0.0.2 lib/ariranha/drivers/postgresql.rb