Sha256: f0e8054cd2d43be8acdd6a2eb018d19e05b45aa56b9d0410c5aafe4cbe592a8b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Astrails
  module Safe
    class Pgdump < Source

      def command
        @commanbd ||= "pg_dump #{postgres_options} #{postgres_username} #{postgres_password} #{postgres_host} #{postgres_port} #{@id}"
#        @commanbd ||= "pg_dump -U #{@config["user"]} #{@config[:option]} #{@config["database"]} -f #{filename}"
#        @commanbd ||= "mysqldump --defaults-extra-file=#{mysql_password_file} #{@config[:options]} #{mysql_skip_tables} #{@id}"
      end

      def extension; '.sql'; end

      protected

      def postgres_options
        @config[:options]
      end

      def postgres_host
        @config["host"] ? "--host='#{@config["port"]}'" : ""
      end

      def postgres_port
        @config["port"] ? "--port='#{@config["port"]}'" : ""
      end

      def postgres_username
        @config["user"] ? "--username='#{@config["user"]}'" : ""
      end

      def postgres_password
        `export PGPASSWORD=#{@config["password"]}` if @config["password"]
      end

      def postgres_skip_tables
        if skip_tables = @config[:skip_tables]
          [*skip_tables].map { |t| "--exclude-table=#{@id}.#{t}" } * " "
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markmansour-safe-0.1.7 lib/astrails/safe/pgdump.rb