Get last possible timestamp for PIT-Recovery with Barman

118 views Asked by At

Is there a way for barman to determine the latest time for a POIT recovery? I think that barman used to tell you that if you specified a too late time for the recovery, he has no data for it.

Currently barman simply performs the recovery and only when the postgre server is booted, the error message appears that data is missing until the too late time.

Example. The last transaction of the WAL files took place at 13:15. The recovery is performed with the command

barman recover pg_server 20230425T090004 --target-time "2023-05-25 13:30:43" --target-action=promote /pgdata/data/userdata Then barman will do it without any problems. But it is only when the postgres server is booted that the error occurs:

FATAL: recovery ended before configured recovery target was reached

Greetings niesel

1

There are 1 answers

0
mike wallace On

Barman does not currently do anything to verify that the requested --target-time is actually reachable. There is an existing issue for adding this functionality but no immediate plans to work on it.

In the meantime you would need to use pg_waldump to validate for yourself that a given timestamp is reachable from the WALs in Barman's archive. For example if the latest WAL segment in the archive was 000000010000000000000073 then you could find the transaction commit timestamps with:

$ pg_waldump main/wals/0000000100000001/000000010000000100000073 | grep 'desc: COMMIT'
rmgr: Transaction len (rec/tot):     34/    34, tx:        739, lsn: 1/730001E0, prev 1/73000148, desc: COMMIT 2023-08-22 10:08:43.876962 UTC

and then verify that there is at least one transaction committed after your proposed --target-time value.