pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Sri Linux <srilinux09@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Need help with PITR for PostgreSQL 9.4.5
Date: Thu, 25 Jun 2020 14:09:57 -0400
Message-ID: <20200625180957.GU3125@tamriel.snowman.net> (raw)
In-Reply-To: <CAFcfow-sD=D591oyV_gmZiEDC1gO7EZVS60ksUh0ChsbE0N8Zw@mail.gmail.com>
References: <CAFcfow9mkj8u6oAsKxniZsCkH-i_f5b9_1OTtkP6=4sjww8cjg@mail.gmail.com>
	<CAKFQuwabUucmjzB2uyoq31qM4pcgP_rOGMQ4jA5P+itCDE9Xxw@mail.gmail.com>
	<CAFcfow-sD=D591oyV_gmZiEDC1gO7EZVS60ksUh0ChsbE0N8Zw@mail.gmail.com>

Greetings,

* Sri Linux (srilinux09@gmail.com) wrote:
> Please find the method used. Please recommend me if I have done
> something wrong...

Yes, you are using 'cp' which is *not* recommended for an archive
command.

> Performing a hot backup using pg_basebackup:
> Create a new folder as the postgres user
> pg_basebackup --xlog --format=t -D /server01/pgbackup/`date %Y%m%d`

Note that your pg_basebackup is going to be copying WAL also, in
addition to the archive_command you've configured.

> Restoring from Backup:
> Extract the contents of base.tar from the backed up folder on top of the PostgreSQL installation folder:
> tar -xf base.tar -C /var/lib/pgsql/9.4/data     (RedHat/CentOS)
> Assuming that there is a single database tar file (named with a number) in the backup, extract the contents of this folder to the /server01 folder:
> tar -xf <number>.tar -C /server01
> Copy any unarchived WAL log files saved from the first step back into the pg_xlog folder appropriate for the OS

Not sure what "first step" means here, but you are configuring PostgreSQL
with a recovery.conf later with a restore command to fetch the WAL it needs
from your archive, so you shouldn't be needing to copy files from one
pg_xlog to another (which is just generally a bad idea..).

Further, the error you're getting, as mentioned, is actually that you've
somehow ended up with WAL for some other cluster in your archive and
when this instance tries to restore it, it complains (quite
understandably).  A sensible tool would prevent this from being able to
happen by checking that the WAL that's being archived to a given
location matches the database that the WAL is for.

As mentioned, you should really be considering using a purpose-built
tool which manages this for you, such as pgbackrest, which has such
checks and provides you with backup/restore commands.

Thanks,

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (10+ messages)  latest in thread

Message-ID: <20200625180957.GU3125@tamriel.snowman.net>
Permalink:  ../20200625180957.GU3125@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20200625180957.GU3125@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sfrost@snowman.net, srilinux09@gmail.com, david.g.johnston@gmail.com
  Subject: Re: Need help with PITR for PostgreSQL 9.4.5
  In-Reply-To: <20200625180957.GU3125@tamriel.snowman.net>
  References: <CAFcfow9mkj8u6oAsKxniZsCkH-i_f5b9_1OTtkP6=4sjww8cjg@mail.gmail.com> <CAKFQuwabUucmjzB2uyoq31qM4pcgP_rOGMQ4jA5P+itCDE9Xxw@mail.gmail.com> <CAFcfow-sD=D591oyV_gmZiEDC1gO7EZVS60ksUh0ChsbE0N8Zw@mail.gmail.com> <20200625180957.GU3125@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox