Class: Martilla::Postgres

Inherits:
Database show all
Defined in:
lib/martilla/databases/postgres.rb

Instance Attribute Summary

Attributes inherited from Database

#options

Instance Method Summary collapse

Methods inherited from Database

create, #initialize, #invalid_options_msg

Methods inherited from Component

#bash

Constructor Details

This class inherits a constructor from Martilla::Database

Instance Method Details

#dump(tmp_file:, gzip:) ⇒ Object

Raises:



3
4
5
6
7
8
9
10
11
12
# File 'lib/martilla/databases/postgres.rb', line 3

def dump(tmp_file:, gzip:)
  if gzip
    bash("set -o pipefail && pg_dump #{connection_string} | gzip -c > #{tmp_file}")
  else
    bash("pg_dump #{connection_string} > #{tmp_file}")
  end

  return if $?.success?
  raise Error.new("Database dump failed with code #{$?.exitstatus}")
end