Module: BoringBackup::Engine

Extended by:
Engine
Included in:
Engine
Defined in:
lib/boring_backup/engine.rb

Constant Summary collapse

NAME =
"postgresql"

Instance Method Summary collapse

Instance Method Details

#client_versionObject



16
17
18
19
20
21
22
# File 'lib/boring_backup/engine.rb', line 16

def client_version
  return unless pg_dump_path

  version(`#{pg_dump_path} --version`)
rescue
  nil
end

#infoObject



7
8
9
10
11
12
13
14
# File 'lib/boring_backup/engine.rb', line 7

def info
  client = client_version
  server = server_version

  return if client.nil? && server.nil?

  {name: NAME, client: client, server: server}
end

#pg_dump_pathObject



32
33
34
35
36
37
38
# File 'lib/boring_backup/engine.rb', line 32

def pg_dump_path
  return @pg_dump_path if defined?(@pg_dump_path)

  @pg_dump_path = ENV.fetch("PATH", "").split(File::PATH_SEPARATOR)
    .map { |dir| File.join(dir, "pg_dump") }
    .find { |path| File.executable?(path) }
end

#server_versionObject



24
25
26
27
28
29
30
# File 'lib/boring_backup/engine.rb', line 24

def server_version
  return unless defined?(::ActiveRecord)

  version(::ActiveRecord::Base.connection.select_value("SHOW server_version"))
rescue
  nil
end