pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Need help with PITR for PostgreSQL 9.4.5
10+ messages / 3 participants
[nested] [flat]

* Need help with PITR for PostgreSQL 9.4.5
@ 2020-06-25 04:00  Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-06-25 04:00 UTC (permalink / raw)
  To: pgsql-general

Hi All,

I am trying to do PINT backup and recovery for the standalone
database which is not in a cluster.

recovery.done is created, after restart database is having errors to start "

< 2020-06-22 16:34:08.280 CDT >LOG:  starting archive recovery
< 2020-06-22 16:34:08.456 CDT >LOG:  restored log file
"000000010000000000000001" from archive
< 2020-06-22 16:34:08.487 CDT >LOG:  WAL file is from different database
system: WAL file database system identifier is 6840038030519879233,
pg_control database system identifier is 6841285371464745049.
< 2020-06-22 16:34:08.487 CDT >LOG:  invalid primary checkpoint record


Please suggest me right method to backup and restore for RHEL OS.


Thanks and Regards
Deepthi

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-06-25 04:36  David G. Johnston <david.g.johnston@gmail.com>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: David G. Johnston @ 2020-06-25 04:36 UTC (permalink / raw)
  To: Sri Linux <srilinux09@gmail.com>; +Cc: pgsql-general

The version you are running is neither up-to-date for its major version
(9.4) nor is the major version being supported.

https://www.postgresql.org/support/versioning/

Thoug a functioning backup is good to have before upgrading, especially
major versions.

On Wednesday, June 24, 2020, Sri Linux <srilinux09@gmail.com> wrote:
>
> I am trying to do PINT backup and recovery for the standalone
> database which is not in a cluster.
>

That is not possible.  Its unclear what exactly you mead/did though.
Consider sharing actual commands/scripts.

< 2020-06-22 16:34:08.487 CDT >LOG:  WAL file is from different database
> system: WAL file database system identifier is 6840038030519879233,
> pg_control database system identifier is 6841285371464745049.
>

You cannot PITR if the WAL doesn’t match the base backup for the cluster
you are trying to restore.

https://www.postgresql.org/docs/9.4/continuous-archiving.html

Or, probably better, consider using a third-party system.

David J.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-06-25 17:38  Sri Linux <srilinux09@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-06-25 17:38 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general

Thank you all for the response,

Please find the method used. Please recommend me if I have done
something wrong...


Thanks and Regards,
sree

On Wed, Jun 24, 2020 at 11:36 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:

> The version you are running is neither up-to-date for its major version
> (9.4) nor is the major version being supported.
>
> https://www.postgresql.org/support/versioning/
>
> Thoug a functioning backup is good to have before upgrading, especially
> major versions.
>
> On Wednesday, June 24, 2020, Sri Linux <srilinux09@gmail.com> wrote:
>>
>> I am trying to do PINT backup and recovery for the standalone
>> database which is not in a cluster.
>>
>
> That is not possible.  Its unclear what exactly you mead/did though.
> Consider sharing actual commands/scripts.
>
> < 2020-06-22 16:34:08.487 CDT >LOG:  WAL file is from different database
>> system: WAL file database system identifier is 6840038030519879233,
>> pg_control database system identifier is 6841285371464745049.
>>
>
> You cannot PITR if the WAL doesn’t match the base backup for the cluster
> you are trying to restore.
>
> https://www.postgresql.org/docs/9.4/continuous-archiving.html
>
> Or, probably better, consider using a third-party system.
>
> David J.
>
>

Attachments:

pint recovery -support.txt (text/plain, 2.8K) download # mkdir /server01/pgarchives # chmod 700 /server01/pgarchives # chown postgres:postgres /server01/pgarchives Enable archiving by modifying postgresql.conf: File is generally located at /var/lib/pgsql/9.4/data/postgresql.conf # WRITE AHEAD LOG # - Settings - wal_level = hot_standby # - Archiving archive_mode = on archive_command = 'cp %p /server01/pgarchives/%f' # REPLICATION # - Sending Server(s) - max_wal_senders = 3 Add the postgres user to the replication role and grant permissions in pg_hba.conf by adding the following line to the end of the file: local replication postgres trust Restart the postgresql server Verify that Write Ahead Logging is enabled by checking the contents of the pg_xlog folder for files with names similar to 000000010000000000000001 This folder is located at /var/lib/pgsql/9.4/data/pg_xlog 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` 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 Ensure that both the PostgreSQL installation folder and the /server01 folder are owned by the postgres user: # chown -R postgres:postgres /var/lib/pgsql/9.4/data (RedHat/CentOS) # chown -R postgres:postgres /server01 (All) Create a recovery.conf file in the installation folder (/var/lib/postgresql/9.4/main/recovery.conf) with the following content and make sure it is owned by the postgres user: restore_command = 'cp /server01/pgarchive/%f %p' The restore_command value should be the functionally opposite command used to archive the WAL files as configured in postgresql.conf In the backup configuration above, WAL files are copied from "%p" to "/server01/pgarchive/%f" The restore_command, therefore, needs to copy from "/server01/pgarchive/%f" to "%p" In addition, it is possible to specify a specific date/time to restore to in this file for a point in time recovery by adding the following line to recovery.conf: recovery_target_time = '2020-0-25 15:32:24 EST' If the recovery_target_time parameter is omitted, the database will be recovered to the most recent transaction Start the PostgreSQL database If all goes well, the recovery.conf file will be renamed to recovery.done upon completion Check the syslog (/var/log/syslog) for information on any errors that might have occurred during startup Confirm that the backup was successfully restored
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-06-25 18:09  Stephen Frost <sfrost@snowman.net>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Stephen Frost @ 2020-06-25 18:09 UTC (permalink / raw)
  To: Sri Linux <srilinux09@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general

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

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-06-25 18:16  Sri Linux <srilinux09@gmail.com>
  parent: Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-06-25 18:16 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general

Thanks for your support.

I will try to restore and provide results shortly without restoring pg_xlog
file

Regards,
Sri

On Thu, Jun 25, 2020 at 1:09 PM Stephen Frost <sfrost@snowman.net> wrote:

> 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
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-11-06 19:30  Sri Linux <srilinux09@gmail.com>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-11-06 19:30 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general

Hi All

I have to start Postgres 9.4.5 vacuum for our production environment. Got
interrupted with the Linux session, is there a way I can monitor if the
vacuum is progressing while I reconnect to the Linux box?

Thanks
Sri

On Thu, Jun 25, 2020 at 1:16 PM Sri Linux <srilinux09@gmail.com> wrote:

> Thanks for your support.
>
> I will try to restore and provide results shortly without restoring
> pg_xlog file
>
> Regards,
> Sri
>
> On Thu, Jun 25, 2020 at 1:09 PM Stephen Frost <sfrost@snowman.net> wrote:
>
>> 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
>>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-11-06 20:11  David G. Johnston <david.g.johnston@gmail.com>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: David G. Johnston @ 2020-11-06 20:11 UTC (permalink / raw)
  To: Sri Linux <srilinux09@gmail.com>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-general

On Friday, November 6, 2020, Sri Linux <srilinux09@gmail.com> wrote:

> Hi All
>
> I have to start Postgres 9.4.5 vacuum for our production environment. Got
> interrupted with the Linux session, is there a way I can monitor if the
> vacuum is progressing while I reconnect to the Linux box?
>
>>
>>>
Please start new email threads when you have new questions.

If you run vacuum manually in a session, and then disconnect that session,
the vacuum stops just like any other command.

David J.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-11-06 21:27  Sri Linux <srilinux09@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-11-06 21:27 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-general

Thank you very much David



On Fri, Nov 6, 2020 at 2:11 PM David G. Johnston <david.g.johnston@gmail.com>
wrote:

> On Friday, November 6, 2020, Sri Linux <srilinux09@gmail.com> wrote:
>
>> Hi All
>>
>> I have to start Postgres 9.4.5 vacuum for our production environment. Got
>> interrupted with the Linux session, is there a way I can monitor if the
>> vacuum is progressing while I reconnect to the Linux box?
>>
>>>
>>>>
> Please start new email threads when you have new questions.
>
> If you run vacuum manually in a session, and then disconnect that session,
> the vacuum stops just like any other command.
>
> David J.
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-11-06 21:34  Sri Linux <srilinux09@gmail.com>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Sri Linux @ 2020-11-06 21:34 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-general

David

Could you please provide me the link to start new questions?

Thanks and Regards
Sri

On Fri, Nov 6, 2020 at 3:27 PM Sri Linux <srilinux09@gmail.com> wrote:

> Thank you very much David
>
>
>
> On Fri, Nov 6, 2020 at 2:11 PM David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>
>> On Friday, November 6, 2020, Sri Linux <srilinux09@gmail.com> wrote:
>>
>>> Hi All
>>>
>>> I have to start Postgres 9.4.5 vacuum for our production environment.
>>> Got interrupted with the Linux session, is there a way I can monitor if the
>>> vacuum is progressing while I reconnect to the Linux box?
>>>
>>>>
>>>>>
>> Please start new email threads when you have new questions.
>>
>> If you run vacuum manually in a session, and then disconnect that
>> session, the vacuum stops just like any other command.
>>
>> David J.
>>
>>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Need help with PITR for PostgreSQL 9.4.5
@ 2020-11-06 21:40  David G. Johnston <david.g.johnston@gmail.com>
  parent: Sri Linux <srilinux09@gmail.com>
  0 siblings, 0 replies; 10+ messages in thread

From: David G. Johnston @ 2020-11-06 21:40 UTC (permalink / raw)
  To: Sri Linux <srilinux09@gmail.com>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-general

On Fri, Nov 6, 2020 at 2:34 PM Sri Linux <srilinux09@gmail.com> wrote:

> Could you please provide me the link to start new questions?
>
>>
>>>
Assuming you are using Gmail...

https://business.tutsplus.com/tutorials/how-to-compose-and-send-your-first-email-with-gmail--cms-276...

David J.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2020-11-06 21:40 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 04:00 Need help with PITR for PostgreSQL 9.4.5 Sri Linux <srilinux09@gmail.com>
2020-06-25 04:36 ` David G. Johnston <david.g.johnston@gmail.com>
2020-06-25 17:38   ` Sri Linux <srilinux09@gmail.com>
2020-06-25 18:09     ` Stephen Frost <sfrost@snowman.net>
2020-06-25 18:16       ` Sri Linux <srilinux09@gmail.com>
2020-11-06 19:30         ` Sri Linux <srilinux09@gmail.com>
2020-11-06 20:11           ` David G. Johnston <david.g.johnston@gmail.com>
2020-11-06 21:27             ` Sri Linux <srilinux09@gmail.com>
2020-11-06 21:34               ` Sri Linux <srilinux09@gmail.com>
2020-11-06 21:40                 ` David G. Johnston <david.g.johnston@gmail.com>

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