diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-22 15:09:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-22 15:09:14 +0000 |
commit | aaf158bcb57386a043d8cb7dc491a2f306a4ac13 (patch) | |
tree | a421128fc10c4b12eaa48a0a18492bb7d64e98b3 /lib/backup/dump/postgres.rb | |
parent | a59aa00d8aeea39a6360d9be12ffee564802c63c (diff) | |
download | gitlab-ce-aaf158bcb57386a043d8cb7dc491a2f306a4ac13.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/backup/dump/postgres.rb')
-rw-r--r-- | lib/backup/dump/postgres.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/backup/dump/postgres.rb b/lib/backup/dump/postgres.rb new file mode 100644 index 00000000000..c07e2c2928a --- /dev/null +++ b/lib/backup/dump/postgres.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +module Backup + module Dump + class Postgres + include Backup::Helper + + 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', 0o600]) + 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 |