debian-mirror-gitlab/lib/backup/dump/postgres.rb
2023-04-23 21:23:45 +05:30

24 lines
618 B
Ruby

# frozen_string_literal: true
module Backup
module Dump
class Postgres
include Backup::Helper
FILE_PERMISSION = 0o600
def dump(database_name, output_file, pgsql_args)
compress_rd, compress_wr = IO.pipe
compress_pid = spawn(gzip_cmd, in: compress_rd, out: [output_file, 'w', FILE_PERMISSION])
compress_rd.close
dump_pid = Process.spawn('pg_dump', *pgsql_args, database_name, out: compress_wr)
compress_wr.close
[compress_pid, dump_pid].all? do |pid|
Process.waitpid(pid)
$?.success?
end
end
end
end
end