I have following: 2 nodes one of which is current production db and another is for fail recovery. I made base backup on first node with following command pg_basebackup -h 127.0.0.1 -U postgres -D bckp -Ft -z -P -R -x and got bacup file base.tar.gz. Now i'm trying to recover it on failover node. I cleared data directory and unzipped there contents of the backup. As I do not need wal logs from master node to stream to this server i should create recovery.conf with at least restore_command specifying command that will copy wal logs from archive directory to xp_log. But it was already there in xp_log. There was file 000000010000000000000017. As i'm new to postgres and linux I decided to move this file to archive directory and set recovery.conf contents to restore_command = 'cp /var/lib/postgresql/archive/%f /var/lib/postgresql/data/%p' then started postgres. It printed ot logs
2015-10-26 14:06:16 UTC [16-3] LOG: starting archive recovery
2015-10-26 14:06:16 UTC [16-4] LOG: restored log file "000000010000000000000017" from archive
2015-10-26 14:06:16 UTC [16-5] LOG: redo starts at 0/17000060
2015-10-26 14:06:16 UTC [16-6] LOG: consistent recovery state reached at 0/17000160
cp: cannot stat ‘/var/lib/postgresql/backup/000000010000000000000018’: No such file or directory
2015-10-26 14:06:16 UTC [16-7] LOG: redo done at 0/17000160
2015-10-26 14:06:16 UTC [16-8] LOG: restored log file "000000010000000000000017" from archive
cp: cannot stat ‘/var/lib/postgresql/backup/00000002.history’: No such file or directory
2015-10-26 14:06:16 UTC [16-9] LOG: selected new timeline ID: 2
cp: cannot stat ‘/var/lib/postgresql/backup/00000001.history’: No such file or directory
2015-10-26 14:06:16 UTC [16-10] LOG: archive recovery complete
2015-10-26 14:06:17 UTC [16-11] LOG: MultiXact member wraparound protections are now enabled
2015-10-26 14:06:17 UTC [30-1] LOG: autovacuum launcher started
2015-10-26 14:06:17 UTC [1-2] LOG: database system is ready to accept connections
Finally it restores and works fine but there are unclear moments for me:
With restoring of 000000010000000000000017 i understand, but why it tries to recover 000000010000000000000018 as it's not there? And what are 00000002.history and 00000001.history files and why it tries to find them?