0

I use the barman ( http://www.pgbarman.org/ ) , for backup and restore on my linux redhat machine

after restore , we start the postgresql as the following

 systemctl start postgresql.service

but postgresql not startup

from the log:

  /var/lib/pgsql/backups/data/pg_log

we seen the following errors

 requested recovery stop point is before consistent recovery point

please advice what is the meaning of this FATAL error?

 more pg_log


 LOG:  database system was interrupted; last known up at 2017-08-06 07:30:49 UTC
 LOG:  restored log file "00000008.history" from archive
 LOG:  starting point-in-time recovery to 2017-08-06 07:30:49.813508+00
 LOG:  restored log file "0000000800000000000000C1" from archive
 LOG:  redo starts at 0/C1000080
 LOG:  recovery stopping before commit of transaction 96139, time 2017-08-06 07:30:49.855629+00
 LOG:  redo done at 0/C1001B90
 FATAL:  requested recovery stop point is before consistent recovery point
 LOG:  startup process (PID 55858) exited with exit code 1
 LOG:  terminating any other active server processes

example - when I start the postgres service:

  systemctl start postgresql.service
  Job for postgresql.service failed because the control process exited with 
  error code. See "systemctl status postgresql.service" and "journalctl -xe" 
  for details.


  ls
  backup_label.old     pg_hba.conf                   pg_hba.conf.2017-08-
  03_13:08  pg_snapshots  pg_xlog                           
  postgresql.conf.2017-08-03_13:03
  barman_xlog          pg_hba.conf.2017-08-03_12:07  pg_ident.conf                 
  pg_stat_tmp   postgresql.conf                   postgresql.conf.2017-08-
  03_13:08
  base                 pg_hba.conf.2017-08-03_12:22  pg_log                        
  pg_subtrans   postgresql.conf.2017-08-03_12:07  postgresql.conf.origin
  global               pg_hba.conf.2017-08-03_12:24  pg_multixact                  
  pg_tblspc     postgresql.conf.2017-08-03_12:22  postmaster.opts
  pg_clog              pg_hba.conf.2017-08-03_12:28  pg_notify                     
  pg_twophase   postgresql.conf.2017-08-03_12:24  recovery.done
  pg_hba_bak.conf.old  pg_hba.conf.2017-08-03_13:03  pg_serial                     
  PG_VERSION    postgresql.conf.2017-08-03_12:28
shalom
  • 451
  • 12
  • 26
  • You still have the recovery file in the pg data. – Florin Asăvoaie Aug 06 '17 at 11:32
  • sorry - what you mean about that I still have this file? – shalom Aug 06 '17 at 11:54
  • Maybe I misunderstood the timing of the error. Does the restore finish correctly or...? That error sounds like you are trying to do Point In Time Recovery with an older point than the base backup... – Florin Asăvoaie Aug 06 '17 at 11:57
  • Try removing recovery.conf from the pg data folder. – Florin Asăvoaie Aug 06 '17 at 11:57
  • @Florin I remove the file and start the postgres , and postgres service was start successfully , so I just asking if by remove this file ( recover.conf ) is ok and not damage the DB ? – shalom Aug 06 '17 at 12:34
  • That file is only required for the Point in Time Restore procedure. When that file is present, the DB will start in recovery mode, not in normal operation mode. – Florin Asăvoaie Aug 06 '17 at 13:08
  • Do not just remove `recovery.conf`. For some reason you have recovery target that's too soon after crash recovery / snapshot. What is the exact restore command you used? What's the content of the generated `recovery.conf`? This *should not* happen and it's not necessarily safe to use this database, there could be corruption due to an incomplete restore. – Craig Ringer Aug 06 '17 at 13:23
  • I use this syntax from barman for restore - barman recover --target-time "$BEGIN_TIME" --remote-ssh-command "ssh postgres@$IP" main-db-server $ID /var/lib/pgsql/data – shalom Aug 06 '17 at 13:28
  • @shalom You cannot recover to the time you start the backup, so there's your problem. If you want the soonest possible recovery point you can use recovery target 'immediate'. – Craig Ringer Aug 07 '17 at 00:19

1 Answers1

0

You forgot to remove the recover.conf file after restoring.

This file is only required for PiTR and not for normal DB operation. The solution is to simply remove it.

Florin Asăvoaie
  • 6,932
  • 22
  • 35
  • in other case , after I removed the recovery.conf , still postgres not start , see my update question in the last , do you think I missed something ? – shalom Aug 06 '17 at 13:20
  • No, that's not it. This error indicates that a recovery target has been set that's too old for this backup. – Craig Ringer Aug 06 '17 at 13:22
  • @CraigRinger, I couldn't agree more. But I think that the problem is actually because the transaction logs were already rolled and the OP didn't remove the file. Since the transaction logs were already rolled, of course, the transactions in the DB are newer than the recovery point specified in the recovery file. – Florin Asăvoaie Aug 06 '17 at 14:53