Class: Backup::Dump::Postgres

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/backup/dump/postgres.rb

Constant Summary collapse

FILE_PERMISSION =

Owner can read/write, group no permission, others no permission

0o600

Instance Method Summary collapse

Methods included from Helper

#compress_cmd, #decompress_cmd

Instance Method Details

#dump(output_file_path, pg_dump) ⇒ Boolean

Triggers PgDump and outputs to the provided file path

Parameters:

  • output_file_path (String)

    full path to the output destination

  • pg_dump (Gitlab::Backup::Cli::Utils::PgDump)

Returns:

  • (Boolean)

    whether pg_dump finished with success



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/backup/dump/postgres.rb', line 15

def dump(output_file_path, pg_dump)
  compress_rd, compress_wr = IO.pipe

  compress_pid = spawn(compress_cmd, in: compress_rd, out: [output_file_path, 'w', FILE_PERMISSION])
  compress_rd.close

  dump_pid = pg_dump.spawn(output: compress_wr)
  compress_wr.close

  [compress_pid, dump_pid].all? do |pid|
    Process.waitpid(pid)
    $?.success?
  end
end