blob: 1a5128b5a6bba53129c50b071bcc363b2d8eb4d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# 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
|