Re: pg_basebackup cannot compress to STDOUNT

From: Paul Förster <paul(dot)foerster(at)gmail(dot)com>
To: Support <admin(at)e-blokos(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_basebackup cannot compress to STDOUNT
Date: 2020-05-09 06:51:55
Message-ID: E46B9A27-0482-4780-A169-5684E8E5119E@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Admin,

> On 08. May, 2020, at 21:31, Support <admin(at)e-blokos(dot)com> wrote:
> 2) Command run?
> ssh postgres(at)nodeXXX "pg_basebackup -h /run/postgresql -Ft -D- | pigz -c -p2 " | pigz -cd -p2 | tar -xf- -C /usr/local/pgsql/data

I don't get it, sorry. Do I understand you correctly here that you want an online backup or a *remotely* running PostgreSQL instance on your local machine?

If so, why not just let pg_basebackup connect remotely and let it do its magic? Something like this:

$ mkdir -p /usr/local/pgsql/data
$ cd /usr/local/pgsql/data
$ pg_basebackup -D /run/postgresql -Fp -P -v -h nodeXXX -p 5432 -U replicator
$ pg_ctl start

You'd have to have a role with replication privs or superuser and you'd have to adapt the port of course.

No need to take care of any WALs manually. It is all taken care of by pg_basebackup. The only real drawback is that if you have tablespaces, you'd have to create all directories of the tablespaces beforehand, which is why we removed them again after initially having tried the feature.

That's basically, how I create async replicas on out site, which is why I additionally add -R to the above command.

Cheers,
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2020-05-09 07:32:53 Re: [GENERAL] import .sql file into PostgreSQL database
Previous Message Tim Cross 2020-05-08 23:14:47 Re: Best way to use trigger to email a report ?