pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
postgres restore & needed history files
3+ messages / 3 participants
[nested] [flat]

* postgres restore & needed history files
@ 2023-01-03 16:03  Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 1 reply; 3+ messages in thread

From: Zwettler Markus (OIZ) @ 2023-01-03 16:03 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

We are using a DIY Postgres backup:
---
psql -c "select pg_start_backup ('Full');"
save -s "${NSR_SERVER}" -g "${NSR_POOL}" "${PGDATA}"
psql -c "select pg_stop_backup();"
---
The pg_wal directory is not saved with it because it is a linked directory.


After some time, we had to perform a point-in-time recovery of 1 of the 5 databases to a point in time 7 days in the past.
We tried to perform a point-in-time restore on another host, which did not work until we copied the contents of the current pg_wal directory.
The current pg_wal directory included 8 history files: 00000002.history to 00000009.history.
The point-in-time restore worked smoodly after it had all these history files.


Afaik, all necessary history files should also be restored by the restore_command.
I had a look at our archived wal backups and found that 00000002.history to 00000008.history files already had been deleted due to our NSR backup retention of 30 days.


Question: Is it necessary to retain all history files?

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

* Re: postgres restore & needed history files
@ 2023-01-06 05:28  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 1 reply; 3+ messages in thread

From: Laurenz Albe @ 2023-01-06 05:28 UTC (permalink / raw)
  To: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Tue, 2023-01-03 at 16:03 +0000, Zwettler Markus (OIZ) wrote:
> We are using a DIY Postgres backup:
> ---
> psql -c "select pg_start_backup ('Full');"
> save -s "${NSR_SERVER}" -g "${NSR_POOL}" "${PGDATA}"
> psql -c "select pg_stop_backup();"
> ---
> The pg_wal directory is not saved with it because it is a linked directory.
>  
>  
> After some time, we had to perform a point-in-time recovery of 1 of the 5 databases to a point in time 7 days in the past.
> We tried to perform a point-in-time restore on another host, which did not work until we copied the contents of the current pg_wal directory.
> The current pg_wal directory included 8 history files: 00000002.history to 00000009.history.
> The point-in-time restore worked smoodly after it had all these history files.
>  
>  
> Afaik, all necessary history files should also be restored by the restore_command.
> I had a look at our archived wal backups and found that 00000002.history to 00000008.history files already had been deleted due to our NSR backup retention of 30 days.
>  
> Question: Is it necessary to retain all history files?

Yes, the history files are an integral part of the database.
You must not delete them from your WAL archive.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





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

* Re: postgres restore & needed history files
@ 2023-01-06 05:34  Christophe Pettus <xof@thebuild.com>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 0 replies; 3+ messages in thread

From: Christophe Pettus @ 2023-01-06 05:34 UTC (permalink / raw)
  To: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>; Laurenz Albe <laurenz.albe@cybertec.at>



> On Jan 5, 2023, at 21:28, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> 
> On Tue, 2023-01-03 at 16:03 +0000, Zwettler Markus (OIZ) wrote:
>> We are using a DIY Postgres backup:
>> ---
>> psql -c "select pg_start_backup ('Full');"
>> save -s "${NSR_SERVER}" -g "${NSR_POOL}" "${PGDATA}"
>> psql -c "select pg_stop_backup();"
>> ---
>> The pg_wal directory is not saved with it because it is a linked directory.
>>  
>>  
>> After some time, we had to perform a point-in-time recovery of 1 of the 5 databases to a point in time 7 days in the past.
>> We tried to perform a point-in-time restore on another host, which did not work until we copied the contents of the current pg_wal directory.
>> The current pg_wal directory included 8 history files: 00000002.history to 00000009.history.
>> The point-in-time restore worked smoodly after it had all these history files.
>>  
>>  
>> Afaik, all necessary history files should also be restored by the restore_command.
>> I had a look at our archived wal backups and found that 00000002.history to 00000008.history files already had been deleted due to our NSR backup retention of 30 days.
>>  
>> Question: Is it necessary to retain all history files?
> 
> Yes, the history files are an integral part of the database.
> You must not delete them from your WAL archive.

It's almost never a good idea to use storage retention rules to expire out files from a PostgreSQL backup archive.  The logic of what files you need to restore a particular backup are not easily mapped onto "delete after x days" rules.




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


end of thread, other threads:[~2023-01-06 05:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 16:03 postgres restore & needed history files Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
2023-01-06 05:28 ` Laurenz Albe <laurenz.albe@cybertec.at>
2023-01-06 05:34   ` Christophe Pettus <xof@thebuild.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