Skip to content

Commit

Permalink
Use pg_basebackup rather than pg_dump for backing up the database
Browse files Browse the repository at this point in the history
This will allow us to backup all databases in the cluster as well
as config files.

https://bugzilla.redhat.com/show_bug.cgi?id=1495192
  • Loading branch information
carbonin committed Oct 24, 2017
1 parent b956c06 commit 271febd
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/gems/pending/util/postgres_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,16 @@ def self.unload_pglogical_extension(opts)
end

def self.backup_pg_compress(opts)
# 3)
# Use pg_dump's custom dump format. If PostgreSQL was built on a system with
# the zlib compression library installed, the custom dump format will compress
# data as it writes it to the output file. This will produce dump file sizes
# similar to using gzip, but it has the added advantage that tables can be restored
# selectively. The following command dumps a database using the custom dump format:

opts = opts.dup
dbname = opts.delete(:dbname)
runcmd("pg_dump", opts, :format => "c", :file => opts[:local_file], nil => dbname)
opts[:local_file]

# discard dbname as pg_basebackup does not connect to a specific database
opts.delete(:dbname)

path = Pathname.new(opts.delete(:local_file))

runcmd("pg_basebackup", opts, :z => nil, :format => "t", :xlog_method => "fetch", :pgdata => path.dirname)
FileUtils.mv(path.dirname.join("base.tar.gz"), path)
path.to_s
end

def self.recreate_db(opts)
Expand Down

0 comments on commit 271febd

Please sign in to comment.